3.4.1
LED Matrix Display Helmet
LED Matrix Display Helmet
What to expect
In this activity, you will experiment with creating a helmet that displays messages and graphics using an LED matrix display.
An LED Matrix is a grid of LEDs arranged in rows and columns. It functions like a low-resolution screen, where each LED acts as a "pixel." By turning specific LEDs on and off, or changing their colors, you can display text, scrolling messages, simple animations, or data visualizations. This all works due to the fact that this system is based on the NeoPixel design.
“NeoPixel” is a common name for individually addressable RGB (Red, Green, Blue) LED light strips and components. Unlike traditional LED strips, where every light must be the same color at the same time, each NeoPixel contains a tiny integrated circuit (a driver chip). This allows you to control the color and brightness of every single LED independently using just one data wire from a microcontroller like the Micro:bit. If you are interested in learning more about NeoPixels, this is an excellent (and very comprehensive) resource: https://learn.adafruit.com/adafruit-neopixel-uberguide/the-magic-of-neopixels.
Connections
We’ve worked with NeoPixel strips before, in Year 1 Unit 2! However, now we are going to do something a little different… You will ultimately connect this to other elements of your Smart eScooter Rider System!
Materials
Micro:bit w/ battery pack (the 2 AAA pack you normally use to power the Micro:bit)
LED Matrix
LED+USB special power and communication cable
USB Battery Bank (This will act as a 5V power supply for the LED Matrix)
Optional:
Helmet
Extreme Velcro
LED long Extension wire
Instructions
This activity has multiple parts. Carefully complete them in order. It’s ok if it takes more than one session to complete!
Part 1: Setup and Testing
Hardware Setup
Connect the long three-wire cable’s connector (Red, White, and Green) to the Din connector on the back of the Matrix. (Hint: Dout is used to chain together multiple Matrices… we won’t be doing that in this project, because it requires more power than we can give it using our hardware.) Do not connect this USB to your computer.
LED+USB special power and communication cable
Connect the short special power and communication cable to the Micro:bit as follows: Green “fork connector” to P0, White fork to GND (ground) as shown. Hint: the easiest way to do this is to put the screw through the hole in the corresponding microbit pin, then put the small black spacer in place on the other side (this helps to ensure your connection only goes to the right pin), then put on the nut. Slide the fork connector between the spacer and the nut. Gently tighten to keep it in place!
The red wire is connected to the USB port, as it provides 5V to power the LEDs. (The Micro:bit is only rated for 3.3V). Very important: The red wire should never connect to the Micro:bit!
Find the “start” LED. The configuration of this LED Matrix is 8 x 32. This means that there are 8 ROWS (horizontal) and 32 COLUMNS (vertical), totalling 256 individually programmable LEDs! These LEDs are arranged in a coordinate system, with the first LED (referred to as 0,0 – think “X” and “Y” just like in math class!) in the upper-left corner of the grid, as shown below. The order of LEDs moves in a “zig-zag” line. Hint: The “Start” LED will be on the same side as the Din connector.
Next, you will test the hardware and learn the basics of the useful programming blocks.
Programming Setup
Launch a new makecode session.
Search for and add the NeoPixel extension.
You’ll also need to add this custom extension made by Alex, a SUPERCHARGE undergraduate: https://github.com/APerhay/led-matrix-extension by copying this link into the search bar in extensions. Your available blocks should look like this:
3. Start by working with the “standard” Neopixel functions with our LED matrix. Add the following code. An explanation of each part is provided below.
A. In Setup, define the neopixel “strip” (yes, it is a matrix, but remember the LEDs are technically arranged into a “zig-zag” strip…) so that there are 256 LEDs. Setting the brightness to 50 (or lower) ensures you use less power. There is no need to have these LEDs at full brightness, and reducing the brightness helps ensure your designs work well with your USB battery bank (and keeps it lasting longer).
B. In this example, pressing button A will make a rainbow pattern on the matrix. With your microbit connected to your programming device (computer) you can open the serial monitor to see an estimate of the power consumption in milliamps. Less than 2500 is ideal.
C. This example makes the active LED pattern “swirl”. You can omit this or try other ideas…
D. This example shows how to change to another brightness level, color, and again lets you see the power consumption.
E. “Black” color of LEDs is functionally the same as turning them all off or blank. (This will be helpful in the next part of this activity.)
Experiment with your own designs before moving on.
Part 2: Pixel Mapper
The “Pixel Mapper” is a helpful online tool Alex (SUPERCHARGE undergraduate) created so you can draw your own graphics to be displayed on the Matrix. You can find that tool here: PIXEL MAPPER TOOL
The main idea of the Pixel Mapper tool is to help define an array (a collection of related special data) that can be used in your block-based programming to describe which color goes where in a single block of code. In other words, it generates a special string (text-based message) that holds all the data (RGB color values for each pixel, in order based on the XY grid you learned about earlier) for the whole matrix. You’ll learn how to use this in your programming later in these steps.
Using the Pixel Mapper:
Start by setting the grid to match the size and shape of your LED Matrix (8 x 32).
If you change the color before clicking on Generate Grid, all squares will change. Hint: Change the color BLACK to turn off all the pixels.
Draw something. In this example, I drew a yellow graphic with a black background. Remember, black pixels are ‘off’.
Click on Copy Array.
Note: You won’t see this as you do it, but what you just copied actually would look like this (based on the current design):
[0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,0,250,250,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,0,0,0,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,0,250,250,0,250,250,0,250,250,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,4,250,250,0,250,250,0,250,250,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,0,250,250,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,250,250,4,250,250,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,250,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
This message describes all 256 LEDs using three values each (R, G, B, which can range from 0 to 255). If you save this string message, you can paste it into “Load Array” (make sure you start and end with square brackets [ ] and it will generate the graphic in the grid!
To use the array in your programming, find the block draw string design with colors in the My NeoMatrix library.
Paste your copied array into the open string argument.
Use this block as you normally would with input conditions… Remember, the My NeoMatrix commands are separate from the NeoPixel commands, so be sure to show or clear them independently.
Download and test your program with your hardware to see your design!
Part 3: Add Your LED Matrix to the Helmet
Attach the Extreme Velcro to the back of the LED Matrix as shown. Hint: It’s easier if you press the velcro sides together, but leave the backing on it until you are ready to stick it onto the helmet.
Carefully remove the backing tape and wrap it firmly around the helmet. Hint: before attaching the final side, point the wiring down so it's easier to connect to your extension wiring later.
Part 4: Challenge
Your challenge is to design common symbols and messages for the helmet when riding the eScooter.
Need some ideas???
Turn signals
STOP
SLOW
HELLO!
Brake lights
….? YOUR CUSTOM (but appropriate 🙂) MESSAGE HERE
See if you can have these messages change every 30 seconds.
Wrap-up
In this activity, you learned how to work with an LED matrix. We’ll revisit concepts from this activity later in this unit.
Next Activity
The next activity will explore common odometry systems used in mobility devices like bikes and e-scooters.