-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudyCounter.ino
More file actions
142 lines (118 loc) · 2.91 KB
/
Copy pathstudyCounter.ino
File metadata and controls
142 lines (118 loc) · 2.91 KB
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
/**
* This program will help me create a studyBreak counter to
* remind me the importance of working in between cycles.
* There will be two method, one for 90 minutes(5400 seconds) and the other one
* for 60(3600) minutes, each with a 10(600) minute break.
*/
#include <Wire.h>
#include "rgb_lcd.h"
//Fields
rgb_lcd lcd;
const int colorR=242;
const int colorG=249;
const int colorB=243;
//Logic
int counter=0;
boolean breakMode=false;
const int minLowDel=5400;
const int minHighDel=3600;
const int minBreak=600;
const int buttonPin=2;
const int buzzerPin=3;
boolean function1;
void setup() {
lcd.begin(16,2); //setting the number of rows and columns
lcd.setRGB(colorR,colorG,colorB);
lcd.print("StudyCounter");
delay(2400);
//Incorporating button
pinMode(buttonPin,INPUT);
pinMode(buzzerPin,OUTPUT);
function1= shortStudyMode();
}
void loop() {
lcd.setCursor(0,1);
int buttonValue = digitalRead(buttonPin);
if(buttonValue==HIGH)
{
if(function1==false)
{
lcd.print(" ");
function1=shortStudyMode();
}
else
{
lcd.print(" ");
function1= longStudyMode();
}
counter=0;
}
if((counter==3600) && (not breakMode) && (function1)) // short-term study mode
{
breakMode= true;
lcd.setRGB(255,249,30);
delay(1000);
digitalWrite(buzzerPin,HIGH);
delay(50);
digitalWrite(buzzerPin,LOW);
delay(1000);
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Take A Break");
counter = 0;
}
else if((counter==5400) && (not breakMode)&& (not function1)) // Long-term study mode
{
breakMode= true;
delay(1000);
lcd.setRGB(250,10,10);
digitalWrite(buzzerPin,HIGH);
delay(50);
digitalWrite(buzzerPin,LOW);
delay(1000);
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Take A Break");
counter=0;
}
else if((breakMode) && (counter==600 )) //break time is up
{
breakMode=false;
lcd.setRGB(0,100,70);
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" "); // erase output
lcd.setCursor(0,0);
lcd.print("Go back to Work");
delay(3000);
counter=0;
function1= shortStudyMode();
}
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(counter);
counter++;
delay(1000);
}
boolean shortStudyMode()
{
lcd.setRGB(120,80,100);
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("60 Min Study");
delay(500);
return true;
}
boolean longStudyMode()
{
lcd.setRGB(105,244,240);
lcd.setCursor(0,0);
lcd.print("90 Min Study");
delay(500);
return false;
}