The Arduino IDE and LED code

To create the LED code, start the Arduino IDE. Then, recall the code you wrote in Chapter 1, Powering on Arduino. The IDE should look like the following screenshot:

The Arduino IDE and LED code

In this code, setting led 13 lit the orange LED on the board. It turns out that the led output pin 13 is also the connection to pin 13 on the connector of the Arduino Uno. If you upload and run this program, the LED connected to pin 13 should flash at the same rate as the LED on the Arduino Uno, as shown in the following image:

The Arduino IDE and LED code

You'll need to add a similar bit of code to get the LEDs connected to pins 12 and 11. Add the code snippet that can be seen in the following screenshot to the sketch on the Arduino IDE:

The Arduino IDE and LED code

Here, you are replicating the code for the led connected to pin 13 to the second led1 connected to pin 12 and the third led2 connected to pin 13. You then program them all to be output pins, and then in the main loop, toggle between high and low. Note that I have two toggling together (pins 13 and 11) with the other (pin 12) toggling in the exact opposite sequence. First, the two outer LEDs should light for one second, and then the inner LED should light.

If one or more of the LEDs don't light, check to make sure that they are pushed firmly down into the board. You can also change the direction of the LED; perhaps you have the leads in the wrong direction on the board.

You can do the same thing with the FLORA board, but you'll need to use alligator clips to connect from FLORA to the breadboard. To do this, build the breadboard as shown earlier. Then, connect the first alligator clip to the right side of one of the resistors on the breadboard. After this, connect it to the GND connector on FLORA. Then, connect the alligator clips to LED 10 and the left side of the top of the breadboard.

Once you have done that, connect the other two LEDs to the LED 12 and LED 9 pins, as shown in the following image:

The Arduino IDE and LED code

Now, bring up the Arduino IDE associated with FLORA. Create the code shown in the following screenshot, patterned after the code you created in Chapter 1, Powering on Arduino:

The Arduino IDE and LED code

In this case, you are going to use D12, D10, and D9 to flash the LEDs on the breadboard. On the IDE, make sure that Adafruit FLORA is set up on the correct COM port. Upload the code and you should see your flashing LEDs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.93.141