Hardware Reference
In-Depth Information
■
Note
not all boards have the same Led pin. For example the arduino ethernet board uses pin 9.
To create libraries, first create a main sketch, and then add the libraries to that sketch. Since the sketch is an
auto-generated header file, the library you create cannot have the same name as the sketch. Let's start by creating the
library's header file,
HelloLibrary.h
. In order to create a new library, you have to use a special part of the Arduino
IDE. In Figure
12-3
, there is a drop down arrow just below the serial monitor button.
Figure 12-3.
SimpleHello.ino sketch with “New Tab” option
Make sure your sketch contains the code from Listing 12-2. Then, in Figure
12-3
, select “New Tab” from the
triangle menu. You will be prompted to create a file. Call this new file
"HelloLibrary.h"
. Once you have created the
new file, enter Listing 12-3.
Listing 12-3.
HelloLibrary Header File
/*
*
* HelloLibrary Header file
*
*/
#ifndef HelloLibrary_h
#define HelloLibrary_h