-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch_name_and_age_lcd_circuit1.ino
50 lines (39 loc) · 1.08 KB
/
switch_name_and_age_lcd_circuit1.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
#include <LiquidCrystal.h>
//create an instance of the LiquidCrystal class called lcd, initialising the relevant pins
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
bool toggleDisplay; // boolean for switching display
struct myData
{
uint8_t Age = 25;
char FirstName[10] = {'F', 'r', 'a', 'n', 'c', 'e', 's', 'c', 'a', '\0'};
} myName;
void setup()
{
// myName.Age = 24;
// myName.FirstName = {'F', 'r', 'a', 'n', 'c', 'e', 's', 'c', 'a', '\0'};
lcd.begin(16,2);
toggleDisplay = true;
}
void loop()
{
switch (toggleDisplay){
case true:
lcd.print(myName.FirstName);
lcd.setCursor(0, 1);
lcd.print(myName.Age);
delay(200);
lcd.clear();
toggleDisplay = false;
break;
case false:
lcd.print(myName.Age);
lcd.setCursor(0, 1);
lcd.print(myName.FirstName);
delay(200);
lcd.clear();
toggleDisplay = true;
break;
default:
break;
}
}