Bright and Shiny Things: Programming with LED’s

Teaching programming using the LED light strips is going much better than expected. I tried it with the 9th grade Algebra class during our weekly programming session using a set of coding lessons I put together. I went so well that though we started by having everyone (about 10 kids) share two LED strips, by the end of the year I had three students from that class build their own.

Student built LED strip.
Student’s LED strip on a sword. The battery can power it for at least 15 minutes.

The coding lessons are still a work in progress, but it has them learn the basics by running some of the test programs, then then explore sequences using for loops. There are a lot of directions to branch off after the for loops. I’ve had some of my Algebra II students make static patterns using linear and exponential functions, while a couple of the kids in my programming class used different functions to make dynamic lighting patterns; our hydroponic system (see here and here) now has a neat LED indicator that runs different sequences depending on if the pumps are running or not.

Some of the students who built their LED strips in the Makerspace posted about their projects: LED Thingy and LED Light Strip Project. The process (rpi-led-strip) is not too hard but required them to be able to do a little physical computing (with Raspberry Pi’s), use ssh and terminal commands (terminal instructions), and then run and write python programs.

Raspberry Pi that controls one of the LED strips from a student’s project.

Since the setup uses the same GitHub repository (rpi-led-strip) it’s also easy to update some of our existing projects like the Wall Anchor.

Wall anchor project.

I am amazed at how much the students have engaged with what are, ultimately, very simple systems (a Raspberry Pi and a strip of 20 lights), and I’m really excited to see where it takes us.

PlottyBot: Pen Drawn Plots

The PlottyBot project looks like a nice introductory project for building computer controlled devices, like 3d printers, laser cutters, and CNC machines. It draws designs using a pen, and is built off a Raspberry Pi Zero, which I’ve been using a lot.

A PlottyBot in action (from https://ben.akrin.com/?p=10244)

It’s now on my list of potential Makerspace Projects.

LED Light Strip with Pi Zero

Raspberry Pi Zero controlling a LED strip, with a hardwired clear button.

I wanted to set up a small (20 LEDs) light strip using a Raspberry Pi Zero, so students could learn how to remotely log in to a device, work with the Linux command line, run python programs, and get visible, real feedback on their progress.

Instructions and code are in the Github rpi-led-strip repository.

Web control for the LED strip.

The repository also has instructions and code for setting up a local server on the Pi so you can control the LED strip via a webpage. Students working on their own LED projects in the Makerspace will appreciate this.

The main idea here was to make the project as simple as possible. The web page is basic with minimal styling, so it should be easy to edit, but I do test out some of the newer HTML input elements, like the color picker. The README in the repository also includes instructions on how to, step by step, add components to the webpage to control the Pi: the “Blue” button is used as the example (it sets the entire strip to blue).

With only 20 LEDs you don’t need an external power supply so everything can be run through the Pi.

Adafruit’s CircuitPython NeoPixel library makes controlling the lights really easy. There are a few example programs in the rpi-led-strip/pyLED/ directory of the repository.

The full strip.

I’ve also included a physical button (it’s optional) that I’m using right now to just clear the LED strip. I may change it to just reboot the Pi, because I anticipate that things will get interesting when I have an entire class trying to connect to one or two devices. So far, I’ve had a small group of four students try this with some success.