LEDs (Programming using Python)
Learn to program using LED strips controlled by a Raspberry Pi.
Since everyone likes LEDs, we've developed an easy way to learn coding by programming LED strips. The LED's are individually addressable, so in learning how to control each light you can get the basic key concepts of coding (variables, logic, lists, arrays). Then, since you're really interested in making light patterns, you can learn about loops, functions, and classes.
Setup
-
Software
-
Install Thonny: You can use any python interpreter, but Thonny makes it easier when you set the interpreter to CircuitPython.
- Set the interpreter to CircuitPython: Either on the bottom right corner of the Thonny Window or through Tools-> Options -> Interpreter. You may also need to set the Port to "RPi" in the Interpreter window.
- Linux: you may have to run the command
sudo usermod -a -G dialout $USER
to get Thonny to communicate.
-
Hardware:
While we have put together a few different designs, the basic hardware consists of a Raspberry Pi Pico (henceforth refered to as a Pico) and a WS2812b LED strip (we default to a length of 20 lights but we've tested strings of 100+ LEDs powered directly from the Pico).
- Parts and design files are on the PicoLED Github Repository.
- [Depreciated] Make your own Pi Strip using a Raspberry Pi Zero or other Raspberry pi computer. (we've mostly switched over to using just Picos since they're much cheaper and easier to set up).
Coding Lessons
Basic coding by controlling a LED light strip using a Raspberry Pi. The default is for the Raspberry Pi Pico
Strips. The code is almost identitical for the Pi computers and the Pico microcontroller, however, they just use
different default GPIO pins: board.D18
for the computers vs board.GP0
or
board.GP15
or board.GP26
for the Pico (although it just depends on your setup).