An issue of falling asleep while reading in bed is the lamp will be on forever. A lamp that fade gently off after a certain time is strategically good for a peaceful couple relationship and for a rainy Sunday project.
- Fading off after 1 hour
- Pseudo color (temperature) control
- 5V powered
The LED used is a SK6812 with 4 channel, R, G, B and warm white.
The microcontroller is a PIC12F1840. A potentiometer gives an analog value for the color.
To control the SK6812, I used the work of Steve Phillips. He discover that the serial protocol is easier to implement than described in the SK6812 ‘datasheet’. Basically “A 0 bit is given when the high voltage time is less than roughly 0.35µs.” and for a 1 bit “As long as you don’t pull low for 50µs between high voltage points, you are fine.”
The analog value is read in a loop and is used to determine the color and intensity of the led. If this value does not change during 1 hour, the color is faded gently.
The PIC code is in this repository : https://github.com/pierre-muth/Bed_Lamp
3D printed body
I used Fusion 360 for the 3D drawing. A set of gears make the potentiometer rotation linked to the base rotation. In order to get a reasonably directional cone of light, I made a “nozzle” like shape, that can be orientated thanks to a ball joint connection.
Printed in PLA during a night on a Prusa i3 MK3, and the inside is painted in white. Files are on thingiverse here.
Thanks for reading!