top of page

Blinking LEDs

Embedded Style “Hello World!”

Overview:
The “Hello World” of embedded systems is simply blinking a led, and it is done using GPIOs.

We will blink 3 leds today using GPIOs 11,12,13.


Task Goal:

To Blink three LEDs, in three steps:

  1. Connecting a circuit with three leds

  2. Running code that will blink two out of the LEDs.

  3. Modifying the code so all three LEDs will light up :-)

Electronics:

For this task, in addition to the board we are using, we will use a few electronic components. Go over them and check that you recognize the pieces of your setup:

  • Breadboard - breadboard (first 1:20 minutes)

  • LEDs (Light-Emitting Diode) - we will use simple LEDs in three different colors. Simple LEDs have two legs, the long one is the positive leg (anode) that will be connected to a GPIO, and a short leg, the negative leg (cathode) that will be connected to ground (GND).

  • Resistors - In our circuit, the resistor will be used to reduce current flow. We will use a 330Ohm resistor for each led.

  • Jumper Wires (M/M) - We will use 4 of them to connect the Bluefruit-board to the breadboard.

 

Source Code:

Folder name: part_3_blinking_leds

 

Instructions:

  1. It is helpful to have the Bluefruit-LE pinout open while you work.

  2. Connect all three leds to the breadboard. Make sure that all three are connected in the same way (the + size in the same place) - it will be easier to do troubleshooting if needed when the setup in order.

  3. Connect a resistor in the following way:

    • One side shall be on the same line of the negative leg of the led,

    • The other leg shall be connected to the GND line of the breadboard.

  4. Use a jumper wire to connect the GND pin on the board to the GND line on the breadboard.

  5. Use a jumper wire to connect each GPIO (11,12,13) to the same line where the positive leg of the led is connected.

  6. Compile and upload our example. Two out of the three leds shall blink!

  7. Modify the code so all three leds will blink in any pattern you like.
     

If you feel that you need a walkthrough for the process detailed above you can use this great link.

 

Your setup shall look like this:

Finished blinking? Here is some more fun:

 

And some more useful information:

  • Don’t know what is the resistance of the resistor you are holding?
    The resistance of each resistor is coded by the colored lines on it. Check it up in this calculator, and this guide for resistor color code (with a video).

If you want to go deeper, here is a tutorial by Sparkfun.

  • When planning a circuit with a LED, the resistor resistance shall match your specific LED.
    A LED resistor calculator can be found here.

 

Get to know Mho the Resistor and his friends by Adafruit :-)

bottom of page