This RGB night light has the ability to control color with hand movements. The device is equipped with three distance sensors, with the help of which the brightness changes when you move or approach your hand. All this is controlled by a microcontroller. Arduino.
Materials:
- Arduino Nano 3.0
- RGB matrix 8x8 1 pc
- Ultrasonic distance sensor HC-SR04 3 pcs
- Chip 74hc595 (shift register) 4 pcs
- Resistors 200 ohms 24 pcs
- 5V2A power supply
- Stand with lampshade
- wires
The luminaire uses a matrix GTM2088, which has a common anode, the pinout in the photo below.
The scheme of the night light is presented below
After soldering, the design has the following form (4 blocks):
- Power Supply
- Registers
- Arduino with hc-sr04 sensors
- Matrix
When developing the sketch, the author set the following parameters:
- At a distance of 1 to 20 cm, the brightness value is set, the closer the hand, the matrix shines brighter, 1 cm sets the maximum brightness value, and the distance of 20 cm is zero. Sensors read data, and then adjusts the brightness.
- If the distance from these values changes by more than 20 cm (move your hand to the side), then this brightness will be fixed for this color.
Brightness sets the PWM signal, it is read on the matrix outputs for 3 groups of R, G, and B. The signal frequency is 60 Hz.
To save the conclusions of the microcontroller to control the matrix, the author used the shift registers 74hc595, they allowed him to get by with 3 pins of the Arduino.
The sketch uses the MsTimer2, Ultrasonic, and SPI libraries. The sketch is attached under the article.
Lamp assembly.
The cartridge is removed from the lamp stand and a hole is made for the matrix.
A block with shift registers is inserted and all this is closed with a circle cut out of polystyrene foam.
The thread is cut off on the ceiling so that it can catch on the stand
Further, a stand from a plastic pipe is added to the structure, having previously made three holes in it for distance sensors.
In the pipe, the bottom is made of polystyrene foam, and the resulting structure is completely assembled.
The assembly of the lamp looks like this:
It remains only to turn on the power and start using the lamp.
Video with the nightlight: