shadmehr
Published © GPL3+

Digital Clock

Do you wanna make your own digital clock? Lets do it!

BeginnerShowcase (no instructions)18,670
Digital Clock

Things used in this project

Story

Read more

Code

Digital_Clock.ino

Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int a = 0;
int b = 0;
int c = 0;
int d = 0;
String e;
int f = 0;
void setup() {
  // put your setup code here, to run once:
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
lcd.begin(16, 2);
lcd.print(c);
lcd.print(":");
lcd.print(b);
lcd.print(":");
lcd.print(a);
lcd.print(" ");
lcd.print(e);
lcd.setCursor(0, 1);
lcd.print("Alarm:");
lcd.print("(8:0:0)AM");
delay(1000);
a = a + 1;
if (a > 59){
  a = 0;
  b = b + 1;
}
if (b > 59){
  b = 0;
  c = c + 1;
}
if (c > 11){
  b = 0;
  c = 0;
  d = d + 1;
  if (d == 2){
    d = 0;
  }
}
if (d == 0){
  e = "PM";
}
if (d == 1){
  e = "AM";
}
if (analogRead(A0)>10){
  b = b + 1;
}
if (analogRead(A1)>10){
  c = c + 1;
}
if (analogRead(A2)>10){
  f = f + 1;
  if (f == 2){
    f = 0;
  }
}
if (f == 0){
  digitalWrite(7,HIGH);
}
if (f == 1){
  digitalWrite(7,LOW);
}
if (b == 0 and c == 8 and e == "AM"){
  digitalWrite(6,HIGH);
  delay(125);
  digitalWrite(6,LOW);
  delay(250);
  digitalWrite(6,HIGH);
  delay(125);
  digitalWrite(6,LOW);
  a = a + 1;
  delay(500);
}
if (b != 0 or c != 8 or e == "PM"){
  digitalWrite(6,LOW);
}
}

Credits

shadmehr
1 project • 3 followers
Contact

Comments

Please log in or sign up to comment.