Loading lesson path
Using Array With Output to Create Flowing LEDs In this chapter we will use several GPIO pins to create a "flowing" effect by turning them on and off in sequence.
A Raspberry Pi with Raspian, internet, SSH, with Node.js installed The onoff module for Node.js 1 x
8 x 220 Ohm resistor 8 x
9 x
The resistor you need can be different from what we use depending on the type of LEDs you use. Most small LEDs only need a small resistor, around 200-500 ohms. It is generally not critical what exact value you use, but the smaller the value of the resistor, the brighter the LED will shine. Click the links in the list above for descriptions of the different components.
Now it is time to build the circuit on our Breadboard. If you are new to electronics, we recommend you turn off the power for the Raspberry Pi. And use an anti-static mat or a grounding strap to avoid damaging it. Shut down the Raspberry Pi properly with the command:
Formula
pi@w3demopi:~ $ sudo shutdown - h nowAfter the LEDs stop blinking on the Raspberry Pi, then pull out the power plug from the Raspberry Pi (or turn of the power strip it is connected to). Just pulling the plug without shutting down properly may cause corruption of the memory card. Look at the above illustration of the circuit. On the Raspberry Pi, connect the female leg of a jumper wire to a GND pin. In our example we used Physical Pin 6 ( GND, row 3, right column) On the Breadboard, connect the male leg of the jumper wire connected to the GND power, to the Ground Bus on the right side. That entire column of your breadboard is connected, so it doesn't matter which row. In our example we attached it to row 1
Formula
For each LED: Connect the LED so that it connects to 2 Tie - Point rows. In our example we connected:LED1 to rows 5 (cathode) & 6 (anode) column J LED2 to rows 8 (cathode) & 9 (anode) column J LED3 to rows 11 (cathode) & 12 (anode) column J LED4 to rows 14 (cathode) & 15 (anode) column J LED5 to rows 17 (cathode) & 18 (anode) column J LED6 to rows 20 (cathode) & 21 (anode) column J LED7 to rows 23 (cathode) & 24 (anode) column J LED8 to rows 26 (cathode) & 27 (anode) column J For each LED: Connect one of the legs of a 220 ohm resistor from the the Ground Bus column on the right side, and the other leg to the right side Tie-Point row where it connects to the cathode leg of the LED. In our example we connected:
For each LED: Connect the female leg of a jumper wire to a GPIO pin on the Raspberry Pi, and the male leg of the jumper wire to the right side Tie-Point row where it connects to the anode leg of the LED. In our example we connected:
7 (
Formula
GPIO 4, row 4, left column) to Tie - point row 6 column F11 (
Formula
GPIO 17, row 6, left column) to Tie - point row 9 column F13 (
Formula
GPIO 27, row 7, left column) to Tie - point row 12 column F15 (
Formula
GPIO 22, row 8, left column) to Tie - point row 15 column F12 (
Formula
GPIO 18, row 6, right column) to Tie - point row 18 column F16 ( GPIO 23, row 8, right column) to
18 ( GPIO 24, row 9, right column) to