Hardware Reference
In-Depth Information
Enter the following code into the Arduino IDE code editor (you
can also copy and paste this code from the Adafruit Learning
System ), and then, with your FLORA connected to your com-
puter via the USB cable, click the upload button in the Arduino
IDE:
// Pin D7 has an LED connected on FLORA.
// give it a name:
int led = 7 ;
// the setup routine runs once when you press reset:
void setup () {
// initialize the digital pin as an output.
pinMode ( led , OUTPUT );
}
// the loop routine runs over and over again forever:
void loop () {
digitalWrite ( led , HIGH ); // turn the LED on (HIGH is
// the voltage level)
delay ( 1000 ); // wait for a second
digitalWrite ( led , LOW ); // turn the LED off by making
// the voltage LOW
delay ( 1000 ); // wait for a second
}
This is a very basic sketch, containing all of the required code
components that your FLORA will look for. The first part of the
sketch is where you assign names to the pins on your FLORA:
// Pin D7 has an LED connected on FLORA.
// give it a name:
int led = 7 ;
In this case, we are associating the name led with pin 7. You
might be confused by this, because there is no pin 7 on the
board. But if you look closely, you will see the label D7 right next
to the tiny LED near the USB port ( Figure 2-2 ). This means that
the LED is always assigned to digital pin 7 on the microcontrol-
ler. For this reason, we use the name led (which is a variable
containing the value 7) to refer to this pin.
Search WWH ::




Custom Search