Sunday, 21 November 2021

Physical Computing: Driving Programmable LED Panels with Python & Raspberry Pi

The Background

I was tinkering with rolls of programmable LEDs and a Raspberry Pi and discovered that there are panels of LEDs built using the same technology.  I saw more opportunities to do "things" with a panel than a 5m strip and it'd be a little easier to manage.

The Idea

I've wanted to help the teachers in my youngster's school with more advanced programming tutorials and I've started to get interested in Physical Computing as I've tinkered more and more with my Raspberry Pi.  I was looking for a way to build a thing that could be controlled using Python code running on an RPi that the 10-12 year old age group could work on.  

The teachers (and students) are quite competent coding with blocks (Scratch, Hour of Code), but I wanted to move things along and upskill some of the older classes, as they'll be in secondary school in a year or two and I expect they'll be writing code there.

I didn't have very clear objectives for this, just some rough ideas

  • Built on Raspberry Pi
  • Uses Python
  • A physical output (for immediate feedback and activity)
  • Relatively cheap

The Hardware

I followed this tutorial to get started.  I bought a WS2812B LED Panel on Amazon rather than use a strip, but everything else is as in the tutorial and it's a much better written piece of work than I've done here, so please spend a few minutes reviewing.

I tried both a regular power supply and and a switching power supply.  I had more success with the switching power supply, as it kept its voltage steady (unlike the first regular power supply I bought that didn't, took two days to debug and ultimately ended up in a WEEE bin) and didn't catch fire (unlike the second one I bought to replace the first one). 😠

I bought some 3mm plywood to build an enclosure to keep everything clean, protected and well presented.  I wanted the students to focus on the sequence, selection and iteration elements of writing code and not be distracted with wiring it all up (though that's fun too!).

I used a breakout connector and ribbon cable to get all the GPIO pins available on the breadboard.


The Build

Following the instructions in the tutorial was straight forward and worked out of the box, once the power supply issues were out of the way.  Construction of a "box" to mount the panel and hold all the components was half-a-day's work and didn't stretch my limited carpentry skills too much. 😅

Some views of my carpentry before the wood oil was applied





The innards, ready for the panel

Power input with label


Here's the finished device, hooked up via ribbon cable to the R-Pi400 and ready to be fired up


The Output

There's a nice function in the test code you'll find in the tutorial that'll turn on specific LEDs by address.  Given a list of LEDs passed as a parameter, it'll iterate through and turn them all on.  

Using that function and a map of the LEDs on the panel (22x22, alternating left-right, right-left from 0) I was able to draw a few different shapes, letters and numbers and even do some cheesy animations:

 

No comments:

Post a Comment