-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCDFUNandteach2advanced.ino
115 lines (95 loc) · 2.16 KB
/
LCDFUNandteach2advanced.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
/*
Code by Dr. Harish with LCD shield on arduino for math and recreation which can be used in calculators on brick games.
*/
// 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);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
randomSeed(analogRead(0));
}
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(3));
if(a==0){
lcd.print("Dr. Harish Fun ");}
if(a==1){
lcd.print("God is great ");
}
if(a==2){
lcd.print("Om Sri Sairam ");
}
lcd.setCursor(0, 1);
int b;
int c;
int d;
float e;
float f;
float g;
a=random(5);
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(" = ");
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(" = ");
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(" = ");
lcd.print(d);
lcd.print(" ");
}
if(a==3){//select sum
f=float(random(10));
g=float(random(5));
e=pow(f,g);
lcd.print(round(f));
lcd.print(" ^ ");
lcd.print(round(g));
lcd.print(" = ");
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(" = ");
lcd.print(e);
lcd.print(" ");
}
delay(3000+random(3000));
}