Introduction: Animated Mood Light & Night Light
Having a fascination that borders on obsession with light I decided to create a selection of small modular PCBs that could be used to create RGB light displays of any size. Having made the modular PCB I stumbled on the idea of arranging them into a hexagon to create a 3D display that could be used to create anything from a simple bedroom night light to a mood light that would not be too out of place sat on a table in a high end restaurant.
Of course other shapes could also be created using the same principals.
Here are some of the animations currently running on the light.
- Snake (Retro)
- Game Of Life
- Waveform Oscillations
- Spinning Patterns (Barber Shop)
The light is currently created in two sizes - Small (96 LEDs) and Large (384 LEDs) but this can be scaled up as required.
WS2812B LEDs - AliExpress
PCBs - ALLPCB
3mm Black Laser Cut Plastic - Plastic Sheet Supplier
White 3D Print Filament - Amazon
Electronic Components - Farnell / Newark
M3 Bolts and Threaded Spacers - Amazon
Toaster Oven - Surface mount component assembly
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Panel PCBs
Starting the journey I wanted a range of small PCBs that could host a number of LED pixels and be joined together in a very simple way without the need for additional wires or connectors. I came up with a very simple design that allowed WS2812B LEDs to be chained together and then pass on the chain to the next PCB.
I created three PCBs with the following pixel dimensions.
- 1 x 8 - 9mm x 72mm
- 4 x 4 - 36mm x 36mm
- 8 x 8 - 72mm x 72mm
For this project only the 4x4 and 8x8 boards are used to create the lights.
The LEDs are arranged in a grid of 9mm in both X and Y dimensions which is fairly close knit but provides enough room to work with when taking the PCB edge connectors into account. The PCBs are created so that when joined together the LED 9mm grid is maintained. PCBs are simply connected together by means of flowing solder from one board to the next.
Each LED has it's own 100nF capacitor for electrical decoupling and to help supply current to the LED on demand.
Shown is the schematic for the 4x4 pixel board complete with the top copper and bottom copper layers to illustrate both the LED layout and the edge connector layout. Markings were added to the silk screen to make it obvious the direction of data transfer between the connectors.
The boards also feature M3 mounting holes on a 18mm by 18mm pitch to simplify mounting and to strengthen the inter-board connections.
Adding a laser cut 3mm milky white acrylic sheet as shown provides a nice diffused effect to the LEDs.
The boards were manufactured by means of applying solder paste to the bottom copper surface mount pads using a stencil. I then placed the components onto the board checking for correct orientation before baking in my toaster oven to flow the solder. I've covered this type of DIY low cost PCB manufacturing in several of my other Instructables builds.
Warning - DO NOT USE any oven that is used for food to cook PCBs as this can lead to contaminated food. I got my PCB toaster oven for £10 ($15) on eBay.
Step 2: Control PCB
With the LEDs done I then wanted the ability to control the LEDs from a microcontroller. I started off using an Arduino nano and this worked great but I wanted to add some more functionality to the light and this became more and more awkward to hack onto the Arduino board. Therefore I decided to create another custom PCB to drive the light.
Here are some of the features I added to my controller board.
- Higher speed microcontroller with more ROM and RAM.
- Logic level FET to allow me to globally switch the LEDs on and off - useful when powering up and for low power operation.
- High speed buffer to convert 3V3 signal from the microcontroller to 5V to drive the LEDs.
- Switch to allow the user to control the light.
- Photo Transistor - to scale the brightness of the LEDs to suit ambient light levels.
- Power supply monitoring - to ensure we did not try and pull more current then the power supply can provide.
- Bluetooth Connector - HC05/HC06.
- WIFI Connector - ESP8266.
- I2C Connector.
- Future Expansion Connector.
The schematic for the board is shown as well as the top and bottom copper layers. The attached BillOfMaterials document lists the components I fitted to the control PCB.
A light sensor is fairly important to the design as the brightness of the WS2812B LEDs can very quickly get too much to look at and even painful at full brightness. Having a light sensor allows the LED brightness to auto scale meaning the display is always pleasant to look at. Vivid in a bright sunlit room and yet still comfortable to watch as a night light in a darkened room.
Again to build the board the solder paste was applied using a stencil, components placed by hand with tweezers and then baked in my trusty toaster oven.
The PCB is powered via a 5V DC supply, this can either come directly from a mains type PSU or via a 2A USB charger socket.
Also shown is my earlier attempt using an Arduino.
Step 3: 3D Printed Skeleton
I did originally toy with using laser cut plastic sheets as diffusers but this left a rather ugly gap in between each of the panels. I ended up 3D printing the surrounding diffuser as this allowed me to create a nice seamless wrapper for the six LED PCBs. It also allowed me to vastly decrease the thickness of the diffuser which provides a much sharper overall display.
Internally the six LED PCBs are held together using a 3D printed skeleton. This skeleton goes into the various M3 holes on the display PCBs holding them in a nice hexagonal pattern.
The 3D printed skeleton also features holes to allow the control PCB to be mounted close to the top laser cut panel allowing for the switch to be accessible and for the light sensor to get a good reading of the ambient light level.
With the boards in position between the skeleton and the diffuser I can then easily solder the boards together by flowing solder between the PCB connection pads. I start by adding solder to the furthest away pad and then rotate the light on its edge to allow gravity to help with the act of flowing the solder to the adjoining pad. Repeat for the three connections and then move to the next board to board connection. On the sixth join between PCBs I only attach the power and ground rails leaving the data connection unconnected. This provides two circular current paths for each board to collect their power similar to how a ring main works for your house internal mains wiring.
Also using the 3D printer are some spacers to allow the top and bottom laser cut panels to be held nicely in place.
The 3D printer files were designed using Sketchup and the source is attached.
Step 4: Laser Cut Top and Bottom
The laser cut parts are very simple hexagon shapes with holes in the right place for the mounting bolts.
The top panel features a small hole for the light sensor and another larger hole for the push switch. While the bottom panel features a hole for the USB power cable as well as two small holes to allow a tie band to be used to provide strain relief for the cable.
The drawings for these parts are included in the Sketchup file in the previous step.
Step 5: Firmware
I picked the PIC24FJ256GA702 device as my main microcontroller as it runs fairly fast at up to 32MHz using its internal oscillator and has tonnes of available program memory and RAM for creating nice animations.
To develop the firmware I used Flowcode as it allowed me to simulate and debug the code as I went which helped to produce nice efficient code that runs at high speed. Flowcode is available for free completely unlocked for 30 days and after that you can choose to purchase or simply sign up to the trial again. It also has a nice online community that are willing to chip in and help should I hit any walls along the way. Saying this all the software could be made using the Arduino IDE or similar, you would just loose the ability to simulate.
I used a PICkit 3 to program the PIC on-board my control PCB. This can be integrated into Flowcode so it compiles and programs via the PICkit at a single mouse click, similar to the download button in Arduino.
The microcontroller I chose did not have on-board EEPROM which initially was a problem as I wanted to save the currently selected animation mode. However it did have user programmable flash memory and so I was able to achieve this functionality in a roundabout way.
The Flowcode program I created is attached. The properties window allows you to select the size of display board used. i.e. 4x4 or 8x8 and this sets up a a load of parameters such as number of LEDs etc that then drive the various animations so that one program can be used on both display sizes.
The user interface for the light is fairly simple. Press the switch for less then three seconds and the light moves to the next mode. Before each mode starts the mode index is shown on each LED panel. Press the switch for more than three seconds and the light switches off. A further press of the switch will bring the light back on and back to the previous selected mode. A loss of power to the light will result in the light resuming it's current operation when the power is restored, including on/off status.
Here are the various animation modes the light can currently do with the present firmware.
- Colour smear - Blended colours in rings
- Game of life - Life form based simulation
- Spinning patterns - Animated patterns of 2, 3 or 4 colours
- Wave generator - Coloured sine waves
- Fixed Colour - Six individual panels of colour rotating
- Shade - Animated panel colours All/Individual
- Lighthouse - Rotating single panel
- Rings - Animated horizontal rings
- Fire - Animated fire effect
- Rain - Animated coloured rain effect
- Fireworks - Animated coloured fireworks effect
- Shifting - Animated scrolling effect
- Snake - Animated retro snake battles
- Snakes - Animated rotating snakes
- Random - Modes 1 to 14 with slow transition (approx 60 seconds)
- Random - Modes 1 to 14 with fast transition (approx 30 seconds)
Each mode has one or more randomised element including speed of animation and other parameters. Some modes also feature randomised elements that can drift or vary over time allowing for more dynamic animations. For example the fire has a randomised amount of fuel that is added on each cycle this amount has fixed upper and lower limits. Over time these limits can increase or decrease allowing the intensity of the fire to fill the display or sink to just the bottom few pixels.
Step 6: Connectivity
The control board is connected to the power supply using a USB A cable or a DC socket cable, both of which can be bought for very low prices on sites such as eBay.
The control board is connected to the unconnected IN socket of the display board using an accessible edge connector and a standard 3-way servo ribbon cable.
The top and bottom laser cut plates are then held in position using M3 pan head bolts and M3 threaded spacers.
Having the option to add Bluetooth and WIFI to my control board allows for future upgrades such as animation updates and smart integration with things such as Amazon Alexa via online services such as ITTT. This is something I am currently investigating.
It would be nice to be able to set the colour of the lamp, the animation mode or even to display a text message just by talking to your smart assistant.
Thanks for looking at my build and I hope I have inspired you to follow in my footsteps or create something similar.
Runner Up in the
Make it Glow Contest