Devices & Components
Arduino Uno Rev3
Standard LCD - 16x2 White on Blue
Single Turn Potentiometer- 10k ohms
Resistor 10k ohm
Pushbutton switch 12mm
220 ohm resisitors
Software & Tools
Arduino IDE
Project description
Code
My code!
c_cpp
Here is the code in case anybody wants to try it for themselves.
1#include <LiquidCrystal.h> 2//to change time, hold chanage time button for 1 second, then use hour chnage and minute change buttons. 3 4LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 5int hour = 12; 6int minutes = 0; 7int seconds = 0; 8int decBtn = 10; 9int hrUp = 9; 10int hrDwn = 8; 11int minUp = 7; 12int minDwn = 6; 13int hrUpDec = 0; 14int hrDwnDec = 0; 15int minUpDec = 0; 16int minDwnDec = 0; 17 18void setup() { 19 lcd.begin(16, 2); 20 pinMode(decBtn, INPUT); 21 pinMode(hrUp, INPUT); 22 pinMode(hrDwn, INPUT); 23 pinMode(minUp, INPUT); 24 pinMode(minDwn, INPUT); 25} 26 27void loop() { 28 if (digitalRead(decBtn) == HIGH) { 29 if (digitalRead(hrUp) == HIGH && hrUpDec == 0) { 30 hrUpDec = 1; 31 hour = hour + 1; 32 } else if (digitalRead(hrUp) == LOW) { 33 hrUpDec = 0; 34 } 35 if (digitalRead(hrDwn) == HIGH && hrDwnDec == 0) { 36 hrDwnDec = 1; 37 hour = hour - 1; 38 } else if (digitalRead(hrDwn) == LOW) { 39 hrDwnDec = 0; 40 } 41 if (digitalRead(minUp) == HIGH && minUpDec == 0) { 42 minUpDec = 1; 43 minutes = minutes + 1; 44 } else if (digitalRead(minUp) == LOW) { 45 minUpDec = 0; 46 } 47 if (digitalRead(minDwn) == HIGH && minDwnDec == 0) { 48 minDwnDec = 1; 49 minutes = minutes - 1; 50 } else if (digitalRead(minDwn) == LOW) { 51 minDwnDec = 0; 52 } 53 seconds = 0; 54 lcd.clear(); 55 if (minutes == 60) { 56 minutes = 0; 57 hour = hour + 1; 58 } 59 if (minutes < 0) { 60 minutes = 59; 61 } 62 if (hour == 13) { 63 hour = 1; 64 } 65 if (hour < 1) { 66 hour = 12; 67 } 68 lcd.print(hour); 69 lcd.print(":"); 70 if (minutes < 10) { 71 lcd.print(0); 72 } 73 lcd.print(minutes); 74 delay(20); 75 } else if (digitalRead(decBtn) == LOW) { 76 lcd.clear(); 77 if (seconds == 60) { 78 seconds = 0; 79 minutes = minutes + 1; 80 } 81 if (minutes == 60) { 82 minutes = 0; 83 hour = hour + 1; 84 } 85 if (minutes < 0) { 86 minutes = 59; 87 } 88 if (hour == 13) { 89 hour = 1; 90 } 91 if (hour < 1) { 92 hour = 12; 93 } 94 lcd.print(hour); 95 lcd.print(":"); 96 if (minutes < 10) { 97 lcd.print(0); 98 } 99 lcd.print(minutes); 100 delay(1000); 101 lcd.clear(); 102 seconds = seconds + 1; 103 } 104}
Downloadable files
Schematic of wiring.
Just the schematic.
Schematic of wiring.

Schematic of wiring.
Just the schematic.
Schematic of wiring.

Comments
Only logged in users can leave comments