Circuit --
Circuit |
Code ---
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | #include <LiquidCrystal.h> #include<EEPROM.h> const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); const int stsp = A0; const int inc = A1; const int dec = A2; const int set = A3; const int buzz = 9; const int relay = 8; int hrs = 0; int Min = 0; int sec = 0; unsigned int check_val = 50; int add_chk = 0; int add_hrs = 1; int add_min = 2; bool RUN = true; bool min_flag = true; bool hrs_flag = true; void setup() { lcd.begin(16, 2); lcd.clear(); lcd.setCursor(0, 0); lcd.print("Mr. Screw Driver"); lcd.setCursor(0, 1); lcd.print("COUNTDOWN TIMER"); pinMode(stsp, INPUT_PULLUP); pinMode(inc, INPUT_PULLUP); pinMode(dec, INPUT_PULLUP); pinMode(set, INPUT_PULLUP); pinMode(buzz, OUTPUT); pinMode(relay, OUTPUT); digitalWrite(relay, LOW); digitalWrite(buzz, LOW); if (EEPROM.read(add_chk) != check_val) { EEPROM.write(add_chk, check_val); EEPROM.write(add_hrs, 0); EEPROM.write(add_min, 1); } else { hrs = EEPROM.read(add_hrs); Min = EEPROM.read(add_min); } delay(1500); INIT(); } void loop() { if (digitalRead(stsp) == LOW) { lcd.clear(); delay(250); RUN = true; while (RUN) { if (digitalRead(stsp) == LOW) { delay(1000); if (digitalRead(stsp) == LOW) { digitalWrite(relay, LOW); lcd.clear(); lcd.setCursor(0, 0); lcd.print(" TIMER STOPPED"); lcd.setCursor(0, 1); lcd.print("----------------"); delay(2000); RUN = false; INIT(); break; } } digitalWrite(relay, HIGH); sec = sec - 1; delay(1000); if (sec == -1) { sec = 59; Min = Min - 1; } if (Min == -1) { Min = 59; hrs = hrs - 1; } if (hrs == -1) hrs = 0; lcd.setCursor(0, 1); lcd.print("****************"); lcd.setCursor(4, 0); if (hrs <= 9) { lcd.print('0'); } lcd.print(hrs); lcd.print(':'); if (Min <= 9) { lcd.print('0'); } lcd.print(Min); lcd.print(':'); if (sec <= 9) { lcd.print('0'); } lcd.print(sec); if (hrs == 0 && Min == 0 && sec == 0) { digitalWrite(relay, LOW); lcd.setCursor(4, 0); RUN = false; for (int i = 0; i < 20; i++) { digitalWrite(buzz, HIGH); delay(100); digitalWrite(buzz, LOW); delay(100); } INIT(); } } } if (digitalRead(set) == LOW) { delay(500); while (min_flag) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("SET MINUTE: "); lcd.print(Min); delay(100); if (digitalRead(inc) == LOW) { Min = Min + 1; if (Min >= 60) Min = 0; delay(100); } if (digitalRead(dec) == LOW) { Min = Min - 1; if (Min <= -1) Min = 0; delay(100); } if (digitalRead(set) == LOW) { min_flag = false; delay(250); } } while (hrs_flag) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("SET HOUR: "); lcd.print(hrs); delay(100); if (digitalRead(inc) == LOW) { hrs = hrs + 1; if (hrs > 23) hrs = 0; delay(100); } if (digitalRead(dec) == LOW) { hrs = hrs - 1; if (hrs <= -1) hrs = 0; delay(100); } if (digitalRead(set) == LOW) { hrs_flag = false; delay(250); } } if (hrs == 0 && Min == 0) { lcd.clear(); lcd.setCursor(0, 0); lcd.print(" INVAID TIME"); delay(2000); } else { EEPROM.write(add_hrs, hrs); EEPROM.write(add_min, Min); } INIT(); } } void INIT() { hrs = EEPROM.read(add_hrs); Min = EEPROM.read(add_min); sec = 0; lcd.clear(); lcd.setCursor(0, 0); lcd.print("Start / Set Time"); lcd.setCursor(4, 1); if (hrs <= 9) { lcd.print('0'); } lcd.print(hrs); lcd.print(':'); if (Min <= 9) { lcd.print('0'); } lcd.print(Min); lcd.print(':'); if (sec <= 9) { lcd.print('0'); } lcd.print(sec); min_flag = true; hrs_flag = true; delay(500); } |
Hello is it possible to adjust the code so that when I press a button it counts down from 15 sec and on the next button from 30 sec and the next one from 60 sec I have already searched the whole net but can't do that find some code and I am unable to write code myself.
Replyi want 45 sec and 40 min
Replyi want 45 sec and 40 min
ReplyJoepke
ReplySee if this is maybe close to what you want.
https://create.arduino.cc/projecthub/mattywausb/one-kitchen-timer-to-cook-it-all-1afdab?ref=tag&ref_id=timer&offset=4
hi
ReplyHello, good morning, engineer
ReplyI have a code to control 4 relays
I can control the relays with this code. But the SMS and call section does not work.
Of course, I want to add a TFT LCD to it. The specifications of the LCD are 3.2 inches for Arduino to show the status of the relays.
No message or call is established when I connect pin GND and D4 or D5.
Can you help us?
where the code for the timer works, I do not have anything showing on the LCD. any thought where to look for my error? The LCD Pot seems to adjust contrast as well. since i am newer, i may be missing something obvious.
Reply4 channel timer on off
ReplyHi i don't have a LCD display right now. i have 0.96 inch oled display. how to change the LCD code for oled. Anybody please help me.
Replysure i can
Replyi can
ReplyHi! Is this code written in C? I want to refer to pieces of this for a project I'm working on but don't want to get mixed up with different versions of C
ReplyHello
ReplyI want to control the device's running time by sending a message with the exact time to run. Can you give me the Arduino code?
Thank you
Hello
ReplyI want to use the code in 5 minutes instead of 1 minute.
How do you code?
Hi, do you know how to add second to the count down?
ReplyIt doesn't work... Can you please help me? The LCD display lights up but does not show any words, just random pixels are shown, Can you help???
ReplyThank you for this..
ReplyWhat if the start button is sensor and the countdown timer is set to 2 hours? can you please help me with the coding ?
Helo . Have u ever resolved yur problem broo. Coz I have d same prob bro I need 8 asap to fix 8. Very needed n my project
ReplyHelo . Have u ever resolved yur problem broo. Coz I have d same prob bro I need 8 asap to fix 8. Very needed n my project
ReplyHelo . Have u ever resolved yur problem broo. Coz I have d same prob bro I need 8 asap to fix 8. Very needed n my project
ReplyHi . is it possible to add a dc motor during the countdown ? and how ?
Reply