Introduction: Big, Auto Dim, Room Clock (using Arduino and WS2811)

First Hello instructables.

This is my first contact with :

  • Instructables
  • Arduino
  • Programmable LED's

So please don't trow rocks at me for noobish mistakes.

Keeping that in mind I'm waiting to read your comments with grate interest and I'm open to any suggestion

Features :

  • big digits ( each digit is approximately the size of a A4 paper).
  • slim in order to fit in a photo frame (a big one).
  • auto dim the light depending on the light in the room.
  • dedicated DST button.

Step 1: Prerequisites

Things I used for this project :

Electronics :

  1. Arduino nano V3.0 (sadly since I can't afford an original arduino I used a chinese clone, for showing my support I donated 2.9 $ to arduino) - 2.9$ on ebay
  2. Digital Light Intensity Sensor Module Photo Resistor for Arduino - 0.99$ on ebay

  3. DS3231 AT24C32 IIC Module Precision Real Time Clock Quare Memory for Arduino - 0.99$ on ebay

  4. DC-DC Buck Converter Step Down Module LM2596 Power Output 1.23V-30V - 0.90$ on ebay

  5. 4m WS2811 led strip 30 leds/m - 12 $ on aliexpress (1 WS2811 IC control 3 LED Chip)

Total cost of electronics : 17.78 $ (without arduino donation)

Miscellaneous :

  1. Heat Shrink Tubing - 7.99$ ebay (assortment, it total 33m)

  2. 20 pcs 5 x 7 cm prototype pcb - 3$ ebay

  3. 3 pcs Micro Switch - 1$ locally bought

  4. Solder - 1$ locally bought

  5. Flux - 1$ locally bought
  6. UTP cable (individual wires used for various connections)
  7. LCD font (http://www.dafont.com/lcd-lcd-mono.font) - free
  8. Cardboard - free loacal supermarket
  9. Polystyrene board - 1.50$ locally bought

Various tools.

Step 2: Preparing - Digit Template

  1. download and install LCD font (http://www.dafont.com/lcd-lcd-mono.font
  2. open word or similar editor and make a template similar to the image (first img)
    • font size ~800,
    • white font color black outline,
    • gray boxes where led strip fits
  3. Print and cut the gray strips with a exacto knife (second img)

Step 3: Preparing - Cut Cardboard and Led Strip

Using the digit template cut the cardboard to size (don't forget to leave space for the dots between hours and minutes)

If your LED strips came with connectors at each end (like mine did) desolder the connector and cut them in sets of 3.

Step 4: Stick the LED Strips

Using the template stick the LED strip on the cardboard.

It's not mandatory but I used a pencil to mark where the LED strips should be placed, this way I got to see the final form before attaching the LED's. It was a good thing since this is how I noticed I left two much space for those dots in the middle, as a result I had stuck the LED strips a little closer.

Step 5: Solder LED Strips

Now starts a long soldering session.

Solder the LED strips in order to form a continues strip.

Notice the order in which to solder the strips in the picture.

For the middle dots I used a single LED strip and covered the middle LED with duct tape.

I used the following color code

  • Blue for ground
  • Green for data
  • Red for Vcc (12v)

Step 6: Wire Arduino on Breadbord

I tried doing a sketch in fritzing but I can't find all the parts :( , Sorry

So here is a list with all the connections and another picture with the setup on a breadboard

Step 7: Test LED's

Before loading this sketch (for which I assume no credit) don't forget to add FastLED library.

If everything went OK the LED's should cycle trough colors. If you have any problems first check your soldered points.

Step 8: Program the Clock

After struggling a little I managed to get a working clock that covers all my needs. I'm sure there is room for improvement.

The code is very commented, if you have any questions please feel free to ask. Also if you have any suggestions, please do tell.

All debugging messages are commented as well.

In order to change the color used you must modify the variable at line 22 ( int ledColor = 0x0000FF; // Color used (in hex)). You can find a list of colors at the bottom of this page: https://github.com/FastLED/FastLED/wiki/Pixel-refe...

If you have problems downloading the code file from instructables here is a mirror : http://bit.ly/1Qjtgg0

Step 9: Make Digits Form Using Polystyrene

Cut each segment in the template printed at the beginning.
Form each digit in the polystyrene using a exacto knife (very hard) or a Hot Wire Cutter.

You can see how I made mine in the pictures.

If you don't have a guitar string you can use just about any thin STEEL wire.

In order to power the Hot Wire Cutter I used the 12v LED power supply.

Also there is a picture with a cut digit. (sorry I forgot to take pictures in the process).

Step 10: Glue Digits and Adding Diffuser

After cutting all 4 digits and the dots glue all of them on the cardboard with the LED strips. (for this process I used
double sided adhesive tape).

In order to diffuse the LED light I used 2 paper sheets on top of the polystyrene. For convenience and aesthetics I used a single A2 size paper folded in two.

Also for finishing touches I've put the entire assembly in a large picture frame.

Comments

author
FiliepV made it! (author)2017-08-17

Thx for this nice project. I made also a pcb for it. I'm totally new with Arduino. Can someone tell me how I can change the color on different times. For example: 8 am red, 10 am green, 10.15 am red 12 am green, 1 pm red, ... I used the clock.ino file of the site.

17-8-2017 21-51-55.png17-8-2017 21-52-15.png
author
MariusB49 (author)2017-08-10

Hello!! Someone have the corect code for this project, cause i get some error from this code. In principle the 'tmElements_t' was not declared.

Can anybody give me a solution? Thanks.

author
AiGreek (author)2017-05-09

Did it a few weeks ago with 3 WS2812/segment and some 3D printing. Everything works but after some time, the clock just stop working (some lag at first then stucked)

author
quieliner (author)2017-04-01

hello, i interest with this project, but i use ws2812b for the segment, is anybody have a code, i try in saxos1983 github it's not available... i want 24 hours clock like onlynoise build.. thanks

author
sayali kedar made it! (author)2017-03-31

error

Capture.JPG
author
sayali kedar (author)2017-03-31

error code please help.

sketch_mar31a.ino:1:23: fatal error: DS3232RTC.h: No such file or directory

compilation terminated.

my gmail. kedarp9697@gmail.com

author
HalilC3 (author)2017-01-30

bu projenizi çok beğendim. bende yapmak istiyorum .kodlamada sorun yaşıyorum. program derlemede hata gösteriyor. bana projenizin detaylarını yollarmısınız. teşekkür ederim. iyi çalışmalar. hcenqiz20@gmail.com

author
onlynoise (author)HalilC32017-01-30

In English please, I can't understand where you need help.

author
FormUser (author)onlynoise2017-03-07

http://urun.gittigidiyor.com/ev-bahce/5-metre-3-ci...

with this product this project Can we work
We only want to use arduino and rtc in the circuit, and we want to show the time on the screen.
Could you help.

author
FormUser (author)HalilC32017-03-06

calisan kod var mi hocam sizde

author
FatmirH (author)2017-02-11

Hi there, this is a cool project. I have already built the clock, but i'm having a problem with the code. When i try to compile it i get the error

exit status 1

'tmElements_t' was not declared in this scope

I have already fastled and DS3232RTC libraries.

Any idea? Thanks.

author
FormUser (author)FatmirH2017-03-04

I am getting the same mistake, how did you solve

author
FatmirH (author)FormUser2017-03-04

I added

#include

and the problem was solved .

author
FormUser (author)FatmirH2017-03-07

Http: //urun.gittigidiyor.com/ev-bahce/5-metre-3-ci ...

tek renk şerit led kullanarak bu projeyi yapabilir miyiz

bu kodlar ile çalışır mı

author
albeagle (author)FormUser2017-03-04

I had to add

#include

author
FatmirH (author)FatmirH2017-02-11

Problem solved :). I had to add

#include <TimeLib.h>

Thankyou :)

author
abdelhadj made it! (author)2016-01-04

Thank you everyone, i made my 1st version based on WS2812B cut by 3.

I will finish it later, maybe try to print the Temperature or add some effects! so many possibilities with those Leds it's awesome!!

10348_10153771518250132_3812867803610409775_n.jpg
author
FormUser (author)abdelhadj2017-03-07

tek renk şerit led kullanarak yapmak mümkün mü

termometre de ekleyebilir miyiz

author
onlynoise (author)abdelhadj2016-01-06

Nice work,

You can get the temperature form RTC module using this code

int t = RTC.temperature();
float celsius = t / 4.0;

float fahrenheit = celsius * 9.0 / 5.0 + 32.0;

You can comment the last line if you want celsius.

author

hi, im almost finished with this great project. I just dont understand how to put this temperature code into the full code. Im total noob to programming ;-) can u help ? thanks a lot

author
abdelhadj (author)onlynoise2016-01-06

Thanks for sharing this with us and thx for the tip i think you meant float t ;)

here is a video of what it looks like : every minute i add the cylon effet example and then it changes the color randomly from preselected array of colors.

Here is my code :

#include <DS3232RTC.h>
#include <Time.h>
#include <Wire.h>
#include <FastLED.h>

#define NUM_LEDS 90 // 5 by segment + 6 in the middle
#define LED_TYPE WS2812
#define COLOR_ORDER GRB // Define color order for your strip
#define BRIGHTNESS 150
#define LED_PIN 5 // Data pin for led comunication

CRGB leds[NUM_LEDS]; // Define LEDs strip

byte digits[10][21] = {
{
0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }
, // Digit 0
{
0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1 }
, // Digit 1
{
1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0 }
, // Digit 2
{
1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1 }
, // Digit 3
{
1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1 }
, // Digit 4
{
1,1,1,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1 }
, // Digit 5
{
1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }
, // Digit 6
{
0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1 }
, // Digit 7
{
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }
, // Digit 8
{
1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1 }
}; // Digit 9 | 2D Array for numbers on 7 segment

byte firstdigit[2][10] = {
{
0,0,0,0,0,0,0,0,0,0 }
, // Digit 0 first number

{
1,1,1,1,1,1,1,1,1,1 }
}; // Digit 1 first number | 2D Array for numbers on 7 segment

bool Dot = true; //Dot state

bool DST = false; //DST state
int last_digit = 0;
//long ledColor = CRGB::DarkOrchid; // Color used (in hex)
long ledColor = CRGB::MediumVioletRed;
long ColorTable[16] = {
CRGB::Amethyst,
CRGB::Aqua,
CRGB::Blue,
CRGB::Chartreuse,
CRGB::DarkGreen,
CRGB::DarkMagenta,
CRGB::DarkOrange,
CRGB::DeepPink,
CRGB::Fuchsia,
CRGB::Gold,
CRGB::GreenYellow,
CRGB::LightCoral,
CRGB::Tomato,
CRGB::Salmon,
CRGB::Red,
CRGB::Orchid};
void setup(){

Serial.begin(9600);

Wire.begin();
FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS);
// FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
pinMode(2, INPUT_PULLUP); // Define DST adjust button pin
pinMode(4, INPUT_PULLUP); // Define Minutes adjust button pin
// pinMode(5, INPUT_PULLUP); // Define Hours adjust button pin

}

// Check Light sensor and set brightness accordingly
void BrightnessCheck(){
const byte sensorPin = 3; // light sensor pin
const byte brightnessLow = 75; // Low brightness value
const byte brightnessHigh = 100; // High brightness value
int sensorValue = digitalRead(sensorPin); // Read sensor
if (sensorValue == 0) {
Serial.println("Brightness High");
LEDS.setBrightness(brightnessHigh);
}

else {
Serial.println("Brightness Low");
LEDS.setBrightness(brightnessLow);
}

};

// Get time in a single number
int GetTime(){
tmElements_t Now;
RTC.read(Now);
//time_t Now = RTC.Now();// Getting the current Time and storing it into a DateTime object
int hour=Now.Hour;
int minutes=Now.Minute;
int second =Now.Second;
if (second % 2==0) {
Dot = false;
}
else {
Dot = true;
};
return (hour*100+minutes);
};

void DSTcheck(){

int buttonDST = digitalRead(2);

Serial.print("DST is: ");
Serial.println(DST);

if (buttonDST == LOW){

if (DST){

DST=false;

Serial.print("Switching DST to: ");
Serial.println(DST);

}

else if (!DST){

DST=true;

Serial.print("Switching DST to: ");
Serial.println(DST);

};

delay(500);

};

}

// Convert time to array needet for display

void TimeToArray(){

int Now = GetTime(); // Get time

int cursor = 90; //116

Serial.print("Time is: ");
Serial.println(Now);

if (Dot){
leds[42]=ledColor;
leds[44]=ledColor;
leds[45]=ledColor;
leds[46]=ledColor;
leds[47]=ledColor;
//leds[48]=ledColor;
}

else {

leds[42]=0x000000;
leds[44]=0x000000;
leds[45]=0x000000;
leds[46]=0x000000;
leds[47]=0x000000;
//leds[48]=0x000000;

};

for(int i=1;i<=4;i++){

int digit = Now % 10; // get last digit in time

if (i==1){

cursor =69; //82

Serial.print("Digit 4 is : ");
Serial.print(digit);
Serial.print(", the array is : ");

for(int k=0; k<=20;k++){

Serial.print(digits[digit][k]);

if (digits[digit][k]== 1){
leds[cursor]=ledColor;
}

else if (digits[digit][k]==0){
leds[cursor]=0x000000;
};

cursor ++;

}; // fin for

Serial.println();
if (digit != last_digit)
{ fadefonction();
ledColor = ColorTable[random(16)];
}
last_digit = digit;

}// fin if

else if (i==2){

cursor =48;

Serial.print("Digit 3 is : ");
Serial.print(digit);
Serial.print(", the array is : ");

for(int k=0; k<=20;k++){

Serial.print(digits[digit][k]);

if (digits[digit][k]== 1){
leds[cursor]=ledColor;
}

else if (digits[digit][k]==0){
leds[cursor]=0x000000;
};

cursor ++;

};

Serial.println();

}

else if (i==3){

cursor =21;

Serial.print("Digit 2 is : ");
Serial.print(digit);
Serial.print(", the array is : ");

for(int k=0; k<=20;k++){

Serial.print(digits[digit][k]);

if (digits[digit][k]== 1){
leds[cursor]=ledColor;
}

else if (digits[digit][k]==0){
leds[cursor]=0x000000;
};

cursor ++;

};

Serial.println();

}

else if (i==4){

cursor =0;

Serial.print("Digit 1 is : ");
Serial.print(digit);
Serial.print(", the array is : ");

for(int k=0; k<=20;k++){
Serial.print(digits[digit][k]);
if (digits[digit][k]== 1){
leds[cursor]=ledColor;
}
else if (digits[digit][k]==0){
leds[cursor]=0x000000;
};
cursor ++;
};
// Serial.println();

};
Now /= 10;
};
};
void TimeAdjust(){
int buttonH = digitalRead(5);
int buttonM = digitalRead(4);
if (buttonH == LOW || buttonM == LOW){
delay(500);
tmElements_t Now;
RTC.read(Now);
int hour=Now.Hour;
int minutes=Now.Minute;
if (buttonH == LOW){
if (Now.Hour== 24){
Now.Hour=1;
}
else {
Now.Hour += 1;
};
}
else {
if (Now.Minute== 59){
Now.Minute=0;
}
else {
Now.Minute += 1;
};
};

RTC.write(Now);
}
}
void fadeall() {
for(int m = 0; m < NUM_LEDS; m++) {
leds[m].nscale8(250);
}
}

void fadefonction () {
static uint8_t hue = 0;
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}

// Now go in the other direction.
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
}
void loop() // Main loop
{
/*BrightnessCheck(); // Check brightness
DSTcheck(); // Check DST
TimeAdjust(); // Check to se if time is geting modified*/
TimeToArray(); // Get leds array with required configuration
FastLED.show(); // Display leds array

/*float t = RTC.temperature();
float celsius = t / 4.0;
Serial.println();
Serial.print("Temp is : ");
Serial.print(celsius);
Serial.println();*/

}

author
ГеннадийБ2 made it! (author)2016-07-27

Cool project! He decided to build this same! (https://youtu.be/yhxRfyJSQ50) Few had to rewrite the code, I have a number of LEDs in segments - more! It wanted to make it shows the date and temperature! I already have DHT11 module! Unfortunately, I do not know how to program the Arduino.

IMAG2825[1].jpgIMAG2828[1].jpgIMAG2830[1].jpgIMAG2840[1].jpg
author

projeniz calisir durumda mi
kod ve devre semasini paylasir misiniz

author
hirez66 made it! (author)2016-05-08

I have made the same project, it is gr8 weekend project

IMAG1816.jpgIMAG1823.jpgIMAG1825.jpgIMAG1821.jpg
author
FormUser (author)hirez662017-03-06

yaptiginiz projeye ait devre semasi ve kodlari paylasir misiniz.
than you

author
joemxwolf (author)hirez662016-10-31

good day sir! can i ask how you code this clock? i want to have a countdown timer similar to this display. can you help me how to program it? only 24 seconds for a shot clock. thanks.

author

Hello Friend! I also plan to assemble LED ws2812b, but none like can`t find a suitable sketch. Could you share your sketch?

author
AntonySoprano (author)hirez662016-06-02

Hello friend. share the sketch, too, wanta thermometer

author
kraiv (author)2017-02-26

Thank you. I did on the 2812b, 2 pieces per segment. The hardest part was cut out pattern ... and it's not a joke, too small partitions in numbers. Thanks again.

author
RandyK50 (author)2017-02-24

hey how do i add the temperature on the 7 digit display ?

i made the clock with the ws2811 led's.

author
PunkyB (author)2017-02-17

Great build! I want build it but i want to edit a little. I want to make a stopwatch that can count until 99,99 seconds, please can you answer me to some questions ?

1. What more parts i need to make it work?

2. Can I add 3 buttons, Start,Stop and reset?

3 Can i use two stopwatches on one Arduino board and have there 4 buttons,Start, Stop 1, Stop 2 and reset?

Thank you in advantage

ps:I don't know nothing about Arduino, I am learning it now and i like it :)

author
BryanM125 (author)2016-12-25

ayuda me brindarías los archivos no soy premiun

metro es bryan_1300@hotmil.com

muchas gracias

author
onlynoise (author)BryanM1252016-12-30

In English, please.
I don't understand where you need help.

author
GlennG14 (author)2016-10-31

Hello, cool project. I was wondering if i can make the same with just a single color led strip instead of RGB?

author
onlynoise (author)GlennG142016-11-01

If they are individually addressable then yes.

author
darkpetter (author)2016-09-27

alguien que me heche una mano hace mucho tiempo que intente hacer este proyecto con ws2811 pero hice todo como el tuto dice y sismpre me sale error en la compilacion de arduiino,,simplemente no funciona,,alguien podria pasarme el codigo completo y correcto ,ya que tengo todo el material pero no me funcione,espero me ayuden porfavor que quiero hacer este reloj tambien

author
JamieR4 (author)2016-06-07

Would the code for this be available please it's great

author
cfurlongtx (author)2016-05-30

Can this clock be modded to add seconds like 00:00:00?

thanks in advance ordering the parts now

author
onlynoise (author)cfurlongtx2016-05-31

Yes it can display the seconds

author
JamieR4 (author)2016-05-29

Brilliant instructable. now its working I'm going to play with the code to see if i can get another bottom to change the colour. Thanks for posting this

author
MartinL136 made it! (author)2016-05-02

Thanks for your instructable ;)

After i realized that i shorted the sdl and scl line it works like a charm.

I've found a bug in your arduino script.

You can't use integer for the ledcolor, you have to use longinteger. Else your unable to use the red color.

Also i added some lines to use different colors at different times of day.

regards Martin

2016-05-02 13.11.11.jpg2016-05-02 13.11.56.jpg
author
MartinL136 made it! (author)MartinL1362016-05-02

Bug and addition

arduino-clock-addon.pngarduino-clock-bug.png
author
svenzy (author)MartinL1362016-05-03

can you post your code on github or directly here? I cant see well on those pictures.. thanks

author
ErikR29 (author)2016-04-18

Works like a charm, after few sleepless nights I finally got it working and to point out I had 0 experience doing arduino stuff or even soldering. Light leds.ino doesn't work, but when I got all required libraries the Clock.ino suddenly passed. Major struggles was the Arduino because I had no clue what it is and how to plug it and what to do with it and I scratched my head alot figuring out why buttons didnt work as I had arduinos GND missing. Would like to have more information on this instructable how to do this on the Arduino side (uploading it) and better image from circuitboard would make this alot easier. I had to redraw the circuit diagram with paint program (win) with all wires connected in different colours to find the missing wires on my board, still 5/5 got 2 more clocks to do!

author
saxos (author)2016-04-04

https://youtu.be/GsmcKU57Mpg

author
rolie1 (author)2016-03-11

PLEASE I need some help. been at this awhile and can't get it to work right. I have the LED's setup and soldered ( WS2812B ). I am using 5 leds per segment (35 per digit plus 2 for the dots). I wave a UNO wired up just like the project shows. The sketches I tried to use are not working ( I have tried to modify the code with the proper amount of LED's that I have but I cant get the darn thing to work properly.All I get are some leds coming on but that it. But then again I'm not sure what sketch to use because of the different led's that some of the sketches use. I am attaching a few pics to show what I have. Again please help me to get this thing working before I am completely bald! 8)

clock_1.jpgUNO_1.jpgUNO_2.jpg
author
saxos (author)rolie12016-03-21

Hi rolie1

Have you tried to turn on all the leds on in a test project?
Maybe there is a fault in the wiring.

Have a look here: https://github.com/saxos1983/Arduino/blob/master/D...

This code uses the FastLed library as in your code from the other post.
Have a look at line 118. Just initialize the LED strip with the WS2812b type in your case:
LEDS.addLeds<WS2812B, LED_DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

author
saxos made it! (author)2016-03-21

Finally, I made it.
I grabbed some tools and managed to finish the clock.

Here are some images and videos for some impressions.
Youtube Video: https://youtu.be/rSLp_9kf9Lg


Here a re

IMG_20160313_102236[1].jpgIMG_20160313_153025[1].jpgIMG_20160319_221534[1].jpgIMG_20160312_111056[1].jpg
author
TigerPilot (author)2016-02-23

You've asked this question before. Are you saying that you didn't google 'DS3231RTC.h' and installed it in the Arduino directory?

About This Instructable

85,634views

722favorites

License:

More by onlynoise:Big, auto dim, room clock (using arduino and WS2811)
Add instructable to: