Ambient Real Time Clock

Ambient Real Time Clock

9+COMPONENTS AND SUPPLIES

Arduino Nano R3×1
Real Time Clock (RTC)×1
Linear Regulator (7805)×1
SparkFun LilyPad Rainbow LED (strip of 7 colors)×1

NECESSARY TOOLS AND MACHINES

Soldering iron (generic)

APPS AND ONLINE SERVICES

Arduino IDE

ABOUT THIS PROJECT

Ambient Lightning Real-Time Clock

Aim

I made this Clock because I have a addressable LED strip laying around and I want to use it. Then I saw my room doesn’t have a good Clock that matches its walls. So I Decided to make a Clock which can change its colors according to users mood or wall color.

Making Process

YouTube Video – 
https://youtu.be/BOfylZIl_ws

I firstly took a 24 x 15 inch plywood board.

Cut LED strip into pieces and paste them on the board

Then After soldering them I cover the whole with a black chart paper

Then paste a thermocoal sheet on top of it and cut the thermocoal with a sharp cutter in shape of 4 seven segment displays along with two holes in center.

Then made my circuit ready using circuits diagram given below

and pasted this all behind the board.

I also ordered a custom pcb for the same from https://jlcpcb.com they provide best pcb prototypes for lowest price from china and ship worldwide fast and secure.

after soldering all my components on my board I removed the breadboard and fixed everything behind the board and covered front section using a thin translucent trace paper.

The clock looks awesome and increase the beauty of wall. customization colors make it perfect for any wall.

If you like this project kindly Subscribe on youtube or visit our website http://robocircuits.com

Thank you for reading!

CODE

Ambient Real Time Clock by RoboCircuits C/C++

RoboCircuits.com

/* The Code is Designed by RoboCircuits
 *  Visit our Website http://robocircuits.com for assistance on this code
 *  This code uses DS3231.h Library download it from http://robocircuits.com
 *  For Full Tutorial Watch video on our YouTube Channel https://youtube.com/robocircuits
 */

#include <Adafruit_NeoPixel.h>
#include <DS3231.h>

int i=0,j=0,k=150;

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      45

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code

  pixels.begin(); // This initializes the NeoPixel library.
  // Setup Serial connection
  Serial.begin(115200);
  
  // Initialize the rtc object
  rtc.begin();
  
  // The following lines can be uncommented to set the date and time
  //rtc.setDOW(WEDNESDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(12, 0, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(1, 1, 2014);   // Set the date to January 1st, 2014
}

void loop() {
  if(digitalRead(2)==HIGH)
  {
  int a= analogRead(A0);
  int b= analogRead(A1);
  int c= analogRead(A2);
  i=map(a,0,1025,0,150); // Green Color
  j=map(b,0,1025,0,150); // Blue Color
  k=map(c,0,1025,0,150); // Red Color
  }
  else
 {
  i= 0;
  j= 0;
  k= 150;
}

// Code for Backlight
  for(int x=29;x<=45;x++)
{
pixels.setPixelColor(x, pixels.Color(i,j,k));
   pixels.show();
}

// Fetching Real Time from rtc
String x=rtc.getTimeStr();
  // Send time
  Serial.println(rtc.getTimeStr());
  int hour1= x.charAt(0);
  int hour2= x.charAt(1);
  int min1= x.charAt(3);
  int min2= x.charAt(4);
  hour1=hour1-48;
  hour2=hour2-48;
  min1=min1-48;
  min2=min2-48;

  // Displaying time on Clock
switch(hour1)
{
//case 0 : zero(0);
//break;
case 1 : one(0);
break;
case 2 : two(0);
break;
  default : nulll(0);
  break;  
}
switch(hour2)
{
case 0 : zero(7);
break;
case 1 : one(7);
break;
case 2 : two(7);
break;
case 3 : three(7);
break;
case 4 : four(7);
break;
case 5 : five(7);
break;
case 6 : six(7);
break;
case 7 : seven(7);
break;
case 8 : eight(7);
break;
case 9 : nine(7);
break;
  default : nulll(7);
  break;  
}
switch(min1)
{
case 0 : zero(15);
break;
case 1 : one(15);
break;
case 2 : two(15);
break;
case 3 : three(15);
break;
case 4 : four(15);
break;
case 5 : five(15);
break;
  default : nulll(15);
  break;  
}   
switch(min2)
{
case 0 : zero(22);
break;
case 1 : one(22);
break;
case 2 : two(22);
break;
case 3 : three(22);
break;
case 4 : four(22);
break;
case 5 : five(22);
break;
case 6 : six(22);
break;
case 7 : seven(22);
break;
case 8 : eight(22);
break;
case 9 : nine(22);
break;
  default : nulll(22);
  break;  
}
 pixels.setPixelColor(14, pixels.Color(i,j,k));
   pixels.show();
   delay(250);
   pixels.setPixelColor(14, pixels.Color(0,0,0));
   pixels.show();
   delay(250);
}



void zero(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void one(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void two(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(0,0,0));
   pixels.show();
}
void three(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void four(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void five(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void six(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void seven(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void eight(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void nine(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(i,j,k));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(i,j,k));
   pixels.show();
}
void nulll(int a)
{
  pixels.setPixelColor(a+0, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+1, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+2, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+3, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+4, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+5, pixels.Color(0,0,0));
   pixels.show();
   pixels.setPixelColor(a+6, pixels.Color(0,0,0));
   pixels.show();
}

SCHEMATICS

Ambient Real Time Clock by RoboCircuits

DOWNLOADRoboCircuits.com

Clock wpganbtnnl

1 comment

Leave a Reply