HPK taruh disini
I was going to
searching some cool project using led to make a clock and I found these
project. This project called Binary Clock with Arduino Uno. The original idea
for this project was designed by Daniel Andrade who shared this project in his
website. It’s an amazing project. But in here, I would like to try to build
that binary clock in simulation using a Proteus Software. With this simulation,
you can see how it’s work before trying with the real thing. I mean real
component.
But, before we starting
make a simulation, I will try to explain about binary clock and how it work.
A Binary Clock
A binary clock is a clock that displays
the time of day in a binary format. Originally, such clocks showed each
decimal digit of sexagesimal time as a binary value, but presently binary
clocks also exist which display hours, minutes, and seconds as binary numbers.
The most common binary clock used six columns of LEDs to represent zeros and ones. Each column represents a single decimal digit, a format known as binary-coded decimal. The bottom row in each column represents 1 (or 20), with each row above representing higher powers of two, up to 23 (or 8).
To read each individual
digit in the time, the user adds the values that each illuminated LED
represents, then reads these from left to right. The first two columns
represent the hour, the next two represent the minute and the last two
represent the second. Since zero digits are not illuminated, the positions of
each digit must be memorized if the clock is to be usable in the dark.
List Component
Because this binary
clock using Arduino Uno who have 14 pin digital outputs, so we will build
binary clock who can show just hour and minute. Here’s the list of all the
items that we will need in order to complete this binary clock.
Parts
- Arduino Uno
- 13x LED’s (here I used blue)
- 13x 220 Ohms Resistor
- 3x 2.2K Ohms Resistor
- 2x Push Buttons
- 1x Normal Button (Switch)
Schematic
Now for the schematic
binary clock, first we need some LED’s and resistor. Just hook up LED’s +
resistor from the pin 1 to 13 arduino. The cathode leg of LED’s connect to
ground.
We use the normal
button to turn on or turn off the binary clock and the push button to set up
the hour and minute clock.
Wiring for normal button to turn
on/off the binary clock
So at the Proteus
Software, we connect LED’s pin at pin from 1 to 13, normal button at pin 0 and push
button at pin a0 for control the minute and pin a5 for control the hour. You
can see the schematic that 1 drew at Proteus.
Arduino
Sketch
Here is the program
that you can write in Arduino Software. You can link this coding to the Proteus
Software, to check that coding work or not.
/*
An
open-source binary clock for Arduino.
Based
on the code from by Rob Faludi (http://www.faludi.com)
Code
under (cc) by Daniel Spillere Andrade, www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/
int
second=0, minute=0, hour=0; //start the time on 00:00:00
int
munit,hunit,valm=0,valh=0,ledstats,i;
void
setup() { //set outputs and inputs
pinMode(1,
OUTPUT);pinMode(2, OUTPUT);pinMode(3, OUTPUT);
pinMode(4, OUTPUT);pinMode(5,
OUTPUT);pinMode(6, OUTPUT);
pinMode(7, OUTPUT);pinMode(8, OUTPUT);pinMode(9,
OUTPUT);
pinMode(10, OUTPUT); pinMode(11, OUTPUT);pinMode(12,
OUTPUT);
pinMode(13, OUTPUT);
pinMode(0,
INPUT);
}
void
loop() {
static
unsigned long lastTick = 0; // set up a local variable to hold the last time we
moved forward one second
//
(static variables are initialized once and keep their values between function
calls)
//
move forward one second every 1000 milliseconds
if
(millis() - lastTick >= 1000) {
lastTick
= millis();
second++;
}
//
move forward one minute every 60 seconds
if
(second >= 60) {
minute++;
second
= 0; // reset seconds to zero
}
//
move forward one hour every 60 minutes
if
(minute >=60) {
hour++;
minute
= 0; // reset minutes to zero
}
if
(hour >=24) {
hour=0;
minute
= 0; // reset minutes to zero
}
munit
= minute%10; //sets the variable munit and hunit for the unit digits
hunit
= hour%10;
ledstats
= digitalRead(0); // read input value, for setting leds off, but keeping count
if
(ledstats == LOW) {
for(i=1;i<=13;i++){
digitalWrite(i,
LOW);}
}
else {
//minutes
units
if(munit
== 1 || munit == 3 || munit == 5 || munit == 7 || munit == 9) { digitalWrite(1,
HIGH);} else { digitalWrite(1,LOW);}
if(munit
== 2 || munit == 3 || munit == 6 || munit == 7) {digitalWrite(2, HIGH);} else
{digitalWrite(2,LOW);}
if(munit
== 4 || munit == 5 || munit == 6 || munit == 7) {digitalWrite(3, HIGH);} else
{digitalWrite(3,LOW);}
if(munit
== 8 || munit == 9) {digitalWrite(4, HIGH);} else {digitalWrite(4,LOW);}
//minutes
if((minute
>= 10 && minute < 20) || (minute >= 30 && minute <
40) || (minute >= 50 && minute < 60)) {digitalWrite(5, HIGH);}
else {digitalWrite(5,LOW);}
if(minute
>= 20 && minute < 40) {digitalWrite(6, HIGH);} else
{digitalWrite(6,LOW);}
if(minute
>= 40 && minute < 60) {digitalWrite(7, HIGH);} else {digitalWrite(7,LOW);}
//hour
units
if(hunit
== 1 || hunit == 3 || hunit == 5 || hunit == 7 || hunit == 9) {digitalWrite(8,
HIGH);} else {digitalWrite(8,LOW);}
if(hunit
== 2 || hunit == 3 || hunit == 6 || hunit == 7) {digitalWrite(9, HIGH);} else
{digitalWrite(9,LOW);}
if(hunit
== 4 || hunit == 5 || hunit == 6 || hunit == 7) {digitalWrite(10, HIGH);} else
{digitalWrite(10,LOW);}
if(hunit
== 8 || hunit == 9) {digitalWrite(11, HIGH);} else {digitalWrite(11,LOW);}
//hour
if(hour
>= 10 && hour < 20) {digitalWrite(12, HIGH);} else
{digitalWrite(12,LOW);}
if(hour
>= 20 && hour < 24) {digitalWrite(13, HIGH);} else
{digitalWrite(13,LOW);}
}
valm
= analogRead(0); // add one minute when pressed
if(valm<800)
{
minute++;
second=0;
delay(250);
}
valh
= analogRead(5); // add one hour when pressed
if(valh<800)
{
hour++;
second=0;
delay(250);
}
}
Here is the video for the tutorial making this simulation. Hopelly, can help you to build this simulation