Helmet Lights
After managing to connect a strip of NeoPixel to micro:bit, we came up with something useful to do with it by making a program that would detect some gestures to signal cycling maneuvers through the LED strip.
These instructions actually describe the adapter made to connect the NeoPixel strip and make it portable with a battery holder. Once built it can be used to signal bicycle maneuvers or anything else by changing the code in micro:bit.
Supplies
- 1x Battery holder
- 1x Switch SK12D07VG4
- 3x 470Ω resistor
- 1x 1000μF capacitor
- 3x 1x19 PinSocket
- 1x 5 header JST P2.50mm Vertical
- 1x micro:bit Expansion Board
- 1x PCB
- 1x micro:bit
Circuit
The circuit to connect a NeoPixel strip to micro:bit is elementary. One important thing is to power the LED strip externally, that is, not to take the power from the micro: bit. We take advantage of the fact that both the micro:bit and the NeoPixel strip are quite tolerant to supply and signaling voltages. Thus, we feed both from a battery holder with two 1.5V alkaline batteries following the circuit that can be seen in the above picture.
Micro:bit Adapter
We started by making an adapter so that the circuit with the micro:bit, the LED strip and the battery would be solid. The starting point was one of the micro:bit to breadboard adapters available in the market. Since we were making the adapter, we thought we would support 3 LED strips instead of just one for future projects.
We designed a simple PCB with KiCad whose Gerber files can be downloaded from this link.
In one of the photos above, can be seen the connections in the JST connector. In this assembly we only use the pins GND, 3.3V and 0 as we only connect one LED strip.
Finally, we made a case with TinkerCAD to be 3D printed.
The final result with everything assembled (PCB, components, batteries, wiring for LED strip, case, adapter and micro:bit) can be seen in the last three photos of this step. The PCB is hot glued to case.
Code
For the code we will take into account that a strip with ten LEDs was mounted. Five will go on the right half of the bike helmet and the other five on the left side.
The design conditions of the program are as follows:
- When the micro:bit accelerometer detects a deceleration, it will indicate that we are braking by lighting all the LEDs in red with a rapid flash for 3 seconds.
- When the gyroscopes detect tilting of the helmet to the right or left, the intention to change direction will be indicated by flashing the LEDs on the corresponding side for 10 seconds.
We use the MakeCode platform to program micro:bit. The resulting program can be seen here.
The code in MakeCode does not allow to calibrate the accelerometer and gyroscope to fine-tune the behavior, although with the default calibration it works quite well already. To have more control over this aspect, you would have to face development in one of the more advanced languages that micro:bit supports, such as MicroPython.
Downloads
Final Result
With a bit of double-sided tape both to hold the LED strip and the control unit, the installation can be done on a helmet. We can see that the above program behaves quite well: