Programmable LED Clock With Arduino
by elecobot in Circuits > Arduino
291 Views, 4 Favorites, 0 Comments
Programmable LED Clock With Arduino
Hello everyone,
This Instructable includes all the process of how I build a DIY Arduino based 3D LIGHT Clock.
As we arduino is a very popular and powerful Microcontroller Which is very useful in school,college projects.
And this Colour full ArduClock can impress anyone cause it has 3D effects also...you can change LED colour combinations as you need.
Downloads
Supplies
To make the Arduclock I used scratch parts such as 12xLEDs,resistors(if required..NOTE Im using a single cell 3.7 volt lipo of 100 mah so i dont need to attach any rsistor) ,Plastic piece(15 cm long 2 cm width) ,some wires ,Lipo battery 1S 3.7 volt,1x dc motor,1x N-S small magnet,1x hall effect/magnetic sensor and the most important thing is the microcontroller..im using arduino 1x UNO SMD version.Circuit Diagram and Code is attached in Step-10.
Tools that I used -
Soldering iron,soldering wire,,Soldering flux,wire stripper and cutter,screwdriver,small drill and glue.
So...take all the parts in your side and lets begin....
Making the Body
1st thake a hard plastic strip(depending upon your parts size--Im taking 15 cm) and draw some line depending upon your LED terminal size(in my case 5mm) And drill some holes so thst the led +,- terminals can go to the other side through the holes. I drilled 24 holes cause I have 12 LEDs.
Connecting LEDs
Insert all LEDs forming any colorcombintion you want in my case G,R,R,R,R,R,R,Y,Y,Y,Y,B (G - Green,R-Red,Y-Yellow,B-Blue)
Connect all Negative Lines of LEDs togather so we will get a common negative line.
Connection With Arduino
I just attache the arduino uno board to the plastic strip with two screws.Then Connected the G LED + pin to 5v .
Other LED R,R,R,R,R,R,Y,Y,Y,Y,B positive pins to the arduino digital pins 12,11,10,9,8,7,6,5,4,3,2.
Connecting Hall Effect/magnetic Censor
I used a 4pin hall effect sensor collected from old CPU cooling fan circuit.
1st pin is connected to 5V,Middle two pins are two output pins we need one which is connected to the Arduino analog pin 0,Attach a 10K ohm resistor to the hall effect sensor pisitive and output pin. 4th pin of the sensor is connected to the Gnd pin to the Arduino.
Attaching Battery
Battery is attached with the arduino using tape. Battey + connected to arduino 5V with a Switch and Battery - to Gnd.
Motor Joint for Rotation
Im using a 12volt 555 motor to rotate the entier thing. On the back side of the Plastic strip i attached a motor shaft joint below the arduino board middle position.
Make sure to attach the motor shaft in right position...Weight in both side of the plastic strip should same or it will vibrate.
In my case I also has some vibrations so to remove that i used a extra load on the other side as shown in 2nd image of step 6.
Attaching Magnet for Magnetic Sensor
I attached a small magnet with the motor base exactly under the hall effect sensor. So when the hall sensor comes above the magnet it will activate.Arduino will read the signal and calculate the LED output timing.
Important Instructions
If motor rotates in wrong direction that will effect your clock light effect and LED blinking speed.
For example video is attached
Downloads
Final Step
Now turn on the Arduino and connect the motro with power suply And check it.
Testing video of my Arduclock Is attached.
Downloads
Circuit Diagram and Code
// ELECOBOT
// 05/05/2024 ARDUCLOCK MARK-1
unsigned int i,n,k,d,y;
unsigned long previousTime = 0;
byte hours = 12; // Begin/Start Time
byte seconds = 00;
int val;
void setup()
{
DDRD = 0xFE;
DDRB = 0xFF;
DDRC = 0xFE;
PORTC = 0x01;
PORTD = 0x03;
PORTB = 0x00;
if(hours == 12)
hours = 0;
}
void loop()
{
while(bit_is_clear(PINC, 0))
{
}
if (millis() >= (previousTime))
{
previousTime = previousTime + 1000;
seconds = seconds +1;
if (seconds == 60)
{
seconds = 0;
minutes = minutes +1;
}
if (minutes == 60)
{
minutes = 0;
hours = hours +1;
}
if (hours == 12)
{
hours = 0;
}
}
k=30;
n=0;
while(n < 60)
{
PORTC |= (1<<5);
if ((k==0) || (k==5) || (k==10) || (k==15) || (k==20) || (k==25) || (k==30) || (k==35) || (k==40) || (k==45) || (k==50) || (k==55))
{
PORTC |= (1<<4);
PORTC |= (1<<3);
}
if ((k==0) || (k==15) || (k==30) || (k==45))
{
PORTC |= (1<<2);
PORTC |= (1<<1);
}
if((k == hours*5) || (( k == 0 ) && (hours == 0)))
{
PORTD |= (1<<2);
PORTD |= (1<<3);
PORTD |= (1<<4);
PORTD |= (1<<5);
PORTD |= (1<<6);
PORTD |= (1<<7);
PORTB |= (1<<0);
}
if(k == minutes)
{
PORTD |= (1<<2);
PORTD |= (1<<3);
PORTD |= (1<<4);
PORTD |= (1<<5);
PORTD |= (1<<6);
PORTD |= (1<<7);
PORTB |= (1<<0);
PORTB |= (1<<1);
PORTB |= (1<<2);
}
if(k == seconds)
{
PORTD |= (1<<2);
PORTD |= (1<<3);
PORTD |= (1<<4);
PORTD |= (1<<5);
PORTD |= (1<<6);
PORTD |= (1<<7);
PORTB |= (1<<0);
PORTB |= (1<<1);
PORTB |= (1<<2);
PORTB |= (1<<3);
PORTB |= (1<<4);
}
delayMicroseconds(140);
PORTD = 0x03;
PORTB = 0x00;
PORTC = 0x01;
PORTD |= (1<<2);
delayMicroseconds(30);
PORTD &= ~(1<<2);
delayMicroseconds(600);
n++;
k++;
if(k == 60)
k=0;
}
while(bit_is_set(PINC, 0))
{
}
}