1#include <LiquidCrystal.h>
2LiquidCrystal lcd1(13, 12, 11, 10, 9, 8);
3LiquidCrystal lcd2(7, 6, 5, 4, 3, 2);
4int push_button = A0;
5int minutes;
6int seconds;
7int updated_minutes;
8int updated_seconds;
9int button = 0;
10int timer_time;
11int duration;
12void setup()
13{
14Serial.begin(9600);
15lcd1.begin(16, 2);
16lcd2.begin(16, 2);
17pinMode(A3, OUTPUT);
18pinMode(A4, OUTPUT);
19pinMode(push_button, INPUT);
20pinMode(A1, INPUT);
21pinMode(A2, INPUT);
22}
23
24void loop()
25{
26digitalWrite(A3,LOW);
27digitalWrite(A4,LOW);
28button = digitalRead(push_button);
29timer_time = analogRead(A1);
30timer_time = timer_time/20;
31duration = analogRead(A2);
32duration = duration/20;
33Serial.print("Timer time = ");
34Serial.println(timer_time);
35Serial.print("Duration = ");
36Serial.println(duration);
37lcd2.setCursor(0,0);
38lcd2.print("Timer Time ");
39lcd2.setCursor(13,0);
40lcd2.print(timer_time);
41lcd2.setCursor(0,1);
42lcd2.print("Duration ");
43lcd2.setCursor(13,1);
44lcd2.print(duration);
45delay(400);
46lcd2.clear();
47 if(button == HIGH )
48 {
49 digitalWrite(A4, HIGH);
50 for(minutes=0;minutes<timer_time;minutes++)
51 {
52 lcd1.setCursor(0,0);
53 lcd1.print("My Timer:- ");
54 lcd1.setCursor(11,0);
55 lcd1.print(minutes);
56 lcd1.print(":");
57 for(seconds=0;seconds<=59;seconds++)
58 {
59 lcd1.setCursor(13,0);
60 lcd1.print(seconds);
61 delay(1000);
62
63 }
64 lcd1.setCursor(11,0);
65 updated_minutes = minutes+1;
66 lcd1.print( updated_minutes);
67 lcd1.print(":");
68 updated_seconds = seconds-59;
69 lcd1.setCursor(13,0);
70 lcd1.print(updated_seconds);
71 digitalWrite(A3, LOW);
72 digitalWrite(A4, HIGH);
73 lcd1.clear();
74 }
75 for(seconds=duration;seconds>=0;seconds=seconds-1)
76 {
77 lcd1.setCursor(0,0);
78 lcd1.print("Duration: ");
79
80 lcd1.setCursor(11,0);
81 lcd1.print(seconds);
82 digitalWrite(A3, HIGH);
83 digitalWrite(A4, LOW);
84
85 delay(1000);
86
87 }
88}
89else
90{
91digitalWrite(A3, LOW);
92}
93}
advit_90
4 years ago
this project is very useful in time limit like you can set 50 seconds in the code and you have to run around the park in 50 sec so if we were not able to come the buzzer and bulb will glow