Introduction: A Different Type of Watch Using RGB Led Ring
This project builds a nice tiny watch with hands built from different colored leds. The seconds hand is red, the minutes hand green and the hours hand blue. We have twelve leds for every hour one. For minutes and seconds we have for every five units one led. Always if the current value is between two leds, we illuminate both with adjusted brightness, this means the led near to the exact value has the higher brightness. Is the value in the middle between the two leds, both have the same brightness.
Step 1: The Hardware
To build this project we need a RGB led ring with WS2812 leds, a 10k trim potentimeter and a D1-Mini ESP8266-12E processor modul . I chose the D1-Mini because it is cheap and very small. It can be supplied by an USB charger. Since it is delivered without soldered connectors you can direct connect the modul with the led ring. The 10k trim potentiometer is used to adjust the brightness.
Step 2: The Code
We use the Arduino IDE to build the program. We need a properly installed ESP8266 environment and two additional Libraries which can be installed using the library manager (see screen shot). Since the signal pin of the led ring is connected with the RX pin (for DMA reasons) it causes weird reaktions while program upload occurs. This is normal since the WS2812 chips do not know what to do with the program code.
The most interesting part of the code is the function where the color values for the leds will be calculated.
We use three arrays for red, green and blue. From the current seconds of the day we calculate which leds are responsible for hours, minutes and seconds and which brightness should the first led have. The second led gets the maximum brightness minus the calculated brightness of the first led. After all three hands are set in the associated arrays, we fill the send buffer with the values for red, green and blue. If two hands share the same led we get mix colors like yellow for mixing seconds and minutes.
You can download the code for the Arduino IDE.
The author Gerald Lechner