-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCDFUNandteachsale2.ino
219 lines (183 loc) · 4.39 KB
/
LCDFUNandteachsale2.ino
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
/*
Code by Dr. Harish with LCD shield on arduino for math and recreation which can be used in calculators on brick games. Best LCD code so far.
It also has a delay between question and answer etc. A lottery of scrolling test with 1/50 probability.
*/
/*
Code by Dr. Harish with LCD shield on arduino for math and recreation which can be used in calculators on brick games.
*/
#include <EEPROM.h>
// include the library code:
#include <LiquidCrystal.h>
#include <math.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
char text[]="Jai sairam, Hare Krishna, Om shivaya";
char texttemp[50];
char text2[]="Success 90%perspiration &10%inspiration";
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
int ep=EEPROM.read(0);
randomSeed(analogRead(A0)+ep);
EEPROM.write(0,random(200)); //TO start different each time its switched on analog doesnt change much unless theres a resistor chain.
// Print a message to the LCD.
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0);
int a;
a=int(random(5));
if(a==0){
lcd.print("Dr. Harish Fun ");}
if(a==1){
lcd.print("God is great ");
}
if(a==2){
lcd.print("Om Sri Sairam ");
}
if(a==3){
lcd.print("JyothiKendriyaV. ");
}
if(a==4){
int year=random(3500)-1000;
if(year<0){
year=year*-10;
lcd.print(year);
lcd.print(" BC ");
}
else{
lcd.print(round(year*1.2));
lcd.print(" AD ");
}
}
lcd.setCursor(0, 1);
int b;
int c;
int d;
float e;
float f;
float g;
int h;
a=random(7);
if(a==0){//select sum
b=int(random(620));
c=int(random(120));
d=b+c;
lcd.print(b);
lcd.print(" + ");
lcd.print(c);
lcd.print(" = ");
delay(5000+random(2500));
lcd.print(d);
lcd.print(" ");
}
if(a==1){//select product
b=int(random(40));
c=int(random(40));
d=b*c;
lcd.print(b);
lcd.print(" * ");
lcd.print(c);
lcd.print(" = ");
delay(5000+random(2500));
lcd.print(d);
lcd.print(" ");
}
if(a==2){//select product
b=int(random(620));
c=int(random(140));
d=b-c;
lcd.print(b);
lcd.print(" - ");
lcd.print(c);
lcd.print(" = ");
delay(5000+random(2500));
lcd.print(d);
lcd.print(" ");
}
if(a==3){//select sum
f=float(random(10)+1);
g=float(random(5));
e=pow(f,g);
lcd.print(round(f));
lcd.print(" ^ ");
lcd.print(round(g));
lcd.print(" = ");
delay(5000+random(2500));
lcd.print(round(e));
lcd.print(" ");
}
if(a==4){//select sum
f=float(random(100)+1.0);
g=float(random(20)+1.0);
e=round(f/g*100.0)/100.0;
lcd.print(int(f));
lcd.print(" / ");
lcd.print(int(g));
lcd.print(" = ");
delay(5000+random(2500));
lcd.print(e);
lcd.print(" ");
}
if(a==5){//select product
b=int(random(40));
c=int(random(40));
h=int(random(20));
d=b+c-h;
lcd.print(b);
lcd.print("+");
lcd.print(c);
lcd.print("-");
lcd.print(h);
lcd.print("=");
delay(5000+random(2500));
lcd.print(d);
lcd.print(" ");
}
if(a==6){//select product
int subind=random(7);
if(subind==0)
lcd.print("Loveall serveall ");
if(subind==1)
lcd.print("Help ever ");
if(subind==2)
lcd.print("Hurt never ");
if(subind==3)
lcd.print("Excercise daily ");
if(subind==4)
lcd.print("F=ma, v=u+at ");
if(subind==5)
lcd.print("2H2 + O2 -> 2H2O ");
if(subind==6){
unsigned int i=0;
int subsubsubind=random(2);
if(subsubsubind==0){
while(text[i]!='\0'){
lcd.print(text[i]);
if(i>=14)
{
lcd.scrollDisplayLeft(); //Scrolling text to Right
}
delay(250);
i++;
}
}
if(subsubsubind==1){
while(text2[i]!='\0'){
lcd.print(text2[i]);
if(i>=14)
{
lcd.scrollDisplayLeft(); //Scrolling text to Right
}
delay(250);
i++;
}
}
}
}
delay(3600+random(4000));
lcd.clear();
}