Light Emitting Dance shades – general purpose party accessory.
About this project
I believe many young adults like to party and with the rapidly growing EDM community a lot of people attend parties with electronic music. I am one of them and you can probably tell where I got the idea to make the LED shades. Projects like this one don’t just keep me occupied in my free time but are also designed to broaden my knowledge in electronics and programming.
I want to share what I have learned working on this project and that’s why I’m making it open-source. I hope this would encourage someone to follow my steps in building the LED shades themselves while exposing design flaws and advantages. This would push the project further and eventually make the shades better for all of us.
Lens from wayfarer style sunglasses are taken out and replaced by circuit boards with 69 LEDs on each. Every LED can be separately controlled much like pixels on 5×7 display. Both left and right circuit boards have a STM32F0 micro-controller for driving the LEDs wired in a matrix. Among with the LEDs there are also other peripherals such as:
- I2C bus which enables both sides of the shades to communicate with each other,
- MEMS motion sensor (accelerometer) to track head movements,
- microphone to make glasses react to music,
- light sensor to make glasses react to light,
- a button for changing modes/effects currently displayed ,
- LiPo/LiIon battery charger,
- mini USB connector for charging and connectivity with a windows based application,
- vibrating alert motor,
- extra ADC input for experimenting, status LED, battery voltage monitor, USART connector for bluetooth to enable connectivity with an android based phone.
Short demonstration how the shades look on me:
Click the picture to see the schematics in PDF form.
Driving 69 LEDs separately would require at least 69 pins which is inefficient. To reduce pin number and thus minimize MCU’s footprint and cost LEDs have to be wired in a matrix and constantly scanned. This is a good article on how LEDs in matrix work written by Make Magazine.
I used standard single color 0603 LEDs I had at home. I checked the datasheet and calculated the current limiting resistor value with the 80% of the rated absolute maximum current that can flow through the diode. I did that in order to make LEDs as bright as possible. Because the matrix is constantly being scanned a single LED is turned on just 1/8 of the time (matrix is scanned vertically and has 8 rows). Effective current through a LED is just 10% of the absolute maximum (which is around 6 mA).
Dual P channel (dual just to reduce footprint area) MOSFETs are switching rows (horizontal) and dual N channel MOSFETs are switching columns (vertical). I used PMDT670UPE and counterpart PMDT290UNE transistors manufactured by NXP. They are cheap, have low drain to source resistance while open and most importantly they have a very small footprint (SOT666 1.7 x 1.3 mm)
I decided to go with STM32F0 series because of cost and support for crystal-less USB. After some research I chose STM32F042G6 in UFQFPN28 case with 4×4 mm footprint. It has 12 bit ADC which is suitable for audio processing. I managed to use all pins on both controllers for either driving the matrix or connectivity with the peripherals.
3-to-8 line decoder/demultiplexer
At first I thought the MCU would have enough pins but at about 60% into drawing the schematics I realized it won’t. I solved this issue with an external 74HC138BQ 3-8 line decoder. It is very cheap and takes only 3.5 x 2.5 mm of area in QFN package. Outputs are inverting (LOW active) what makes it perfect for driving P channel FETs.
Because of lack of space programming is done with the TAG connect. I think it’s convenient because it takes less space than other solutions. It also does not require any soldering. You can get TAG connect footprint for Altium designer here.
Power supply and management
Power is supplied from an external LiIon batter-y/ies with integrated protection circuit. I’m using two 200 mAh LiPo batteries each mounted on one side of the glasses. They should last for about two hours of use.
Voltage delivered by battery varies with the charge in the battery so some kind of management and regulation had to be implemented.
Vcc line regulator
TPS63031 buck/boost switching regulator with fixed output of 3.3V regulates the input voltage. It is rated for 1.2A and makes a perfect choice with 2.5 x 2.5 mm footprint. It requires an external inductor and input and output capacitors.
Single push button on/off
The input of TPS63031 is constantly connected to the battery and in shutdown mode when the device is not being used. Shutdown current is only few uA and I calculated it would take around 10 years to completely discharge the battery. Take a look at the bottom picture.
Let’s assume that the device is in shutdown mode. POWER net is connected to Enable pin of the switching regulator. Pull-down resistor prevents the device to power on. When someone pushed the S1 button the battery potential minus the schottky diode voltage drop (0.3V) is forced on the POWER net what causes the regulator to turn on and MCU to boot. Once the MCU is booted it sets the PA15 pin to high. The button can now be released. When the device needs to be shut down another press on the button once again forces the battery potential on the POWER net, however, it also forces it on the PB6 pin and since the MCU is operating (it wasn’t before) it detects that input pin PB6 is high and sets PA15 pin to low. Device is still functioning as long as the button is pushed down. Once the button is released pull-down does the trick and pull POWER net (connected to enable pin of TPS63031 ) to ground what makes the device to shut down.
MCP73811, a 500 mA charger IC is on board. It has both CC and CV modes and manages them automatically. It is powered from USB’s Vbus (5V) and works as linear drop-down regulator. It produces some heat and requires some copper around it on the PCB to ensure good thermal conductivity and dissipation. Like any linear regulator this one too requires external capacitors. IC is in SOT23-5 housing and has a status pin. It is used to either monitor the charge status with a gpio pin on the MCU or with a LED which stays on during the charge and turns off when the battery is fully charged.
Sensors make the LED shades react to movement, light and sound.
The shades can track head movement with LIS3DH MEMS motion sensor (accelerometer). It does not only output data on I2C but also have two interrupt pins that can be programmed to trigger at various events. I chose this sensor because it’s simple and cheap. I also have around 100 of them at home. In addition the sensor features three 12 bit ADCs of which I only used 2. One for temperature sensor (with NTC thermistor) and one for measuring battery voltage.
Measuring battery voltage
Because the voltage of the battery can be grater than the supply of the ADC in the motion sensor a divider has to be used. However, just a resistor divider isn’t enough because it would slowly but surely drain the battery. That can be solved with either using extremely large resistors with a great impact on measurement accuracy or with a transistor that switches the divider on just when it is needed. A single N channel MOSFET is there to enable the divider. POWER net is the same net that enables the Vcc rail regulator.
Active element for light sensing is TEMT6200FX01, a phototransistor commonly used in LCDs with automatic brightness. It is cheap, simple and with 0805 footprint. Gain is set with collector resistor. Emitter resistor is there to compensate for thermal drift of the transistor.
Sound pickup is done with a 4 mm electret microphone capsule. The most standard audio pre-amplifier MAX4466 is used to produce usable signals. Because only low frequency sounds are needed to extract the ‘beat’ or tempo from music the passive elements around the amplifier are calculated to work as a light low pass filter. Output of the amplifier is directly connected to ADC where it is sampled and processed.
Due to small size the layout and routing was quite complex. Small holes enable the user to actually see through the glasses. Boards have 2 layers and are routed with 6 mil clearance and 6 mil minimum trace width. There are components on the front and on the back side. The master side (left) is more dense with components since it has got power management.
Prototype PCBs were manufactured by PCBWay. Their rapid prototype service is fast (5 days from gerbers to PCBs in my hands), reliable and the quality of the PCBs is completely comparable with a local manufacturer. Not to mention 20 boards with 6mil clearance were just 30$ including shipping. I’ll definitely order again.
Click the pictures to see prints in PDF form.
Current version: v0.4
Difference between v0.1, v0.2, v0.3 and v0.4
The first version of the board has few errors such as shifted pins on a 3-8 line decoder footprint and misplaced components. Besides that the majority of the board functions as expected. The new version (v0.3) features bigger holes, resistors just on the vertical side of the matrix and a vibration alert motor. Version v0.2 was designed but never fabricated due to new ideas and
consequently a new version – v0.3.
v0.4 is for now the final version where everything should work and all footprints are correct. Use v0.4 gerbers for PCB fabrication.
Bill of materials
The (almost) complete bill of materials with short part description can be accessed on this link. As I buy most components on farnell the BOM also has farnell codes in it.
This was the first part of the prototype circuit. It contains power management such as 3.3V switching converter, LiIon charger and protection circuit. On the same board is also a test circuit for light sensor and microphone amplifier. The test circuit became fully functional after fixing some layout mistakes and tweaking some values of passive elements. In the end I decided to get rid of the battery protection based on low part availability and the fact that most of small batteries already have protection built-in.
Second test circuit was with a matrix and a multiplexer. With this one I tested how fast can the MCU scan the matrix. The refresh rate of the whole matrix was 72 kHz (14 us) which is 72 times faster than 1 kHz design requirement.
The last thing to test was how well I copied the shape of the lens. Second version fit perfectly.
After all prototypes I was confident enough to order the first PCBs. As expected they came with some design mistakes. The biggest one was shifted pins on a footprint of demultiplexer. I had to perform so called micro surgery of electronics and imitate a bonding machine to solder the component, twice.
LED shades displaying animations and text.
Software can be found on github repository.
- LED matrix driver
- LIS3DH driver
- I2C communication
- ADC initialization for light sensor
- Custom animations
- Running text
- Audio processing
- Single button on/off
- USB support
New in November 2016: Shades editor, Windows application for editing animations or graphics shown by the shades. C# project is on GitHub.
To compile, install Visual studio community, the “Free, fully-featured IDE for students, open-source and individual developers”.