-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_stickGame.ino
98 lines (90 loc) · 1.47 KB
/
main_stickGame.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
#include <LiquidCrystal.h>
//ci dessou les pin relies aux pin du lcd
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
byte armsDown[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};
byte armsUp[8] = {
0b00100,
0b01010,
0b00100,
0b10101,
0b01110,
0b00100,
0b00100,
0b01010
};
byte armsRight[8] = {
0b00100,
0b01010,
0b00100,
0b00101,
0b01110,
0b10100,
0b00100,
0b01010
};
byte armsLeft[8] = {
0b00100,
0b01010,
0b00100,
0b10100,
0b01110,
0b00101,
0b00100,
0b01010
};
int Xpos=0;
int Ypos=1;
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(A2, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
lcd.createChar(0, armsDown);
lcd.createChar(1, armsUp);
lcd.createChar(2, armsRight);
lcd.createChar(3, armsLeft);
}
void loop(){
lcd.setCursor(Xpos,Ypos);
lcd.write((byte)0);
if(Xpos>15){
Xpos=0;
}
if(Xpos<0){
Xpos=15;
}
if(digitalRead(A0)){
lcd.write((byte)2);
Xpos++;
delay(50);
}
if(digitalRead(A1)){
Xpos--;
lcd.setCursor(Xpos,Ypos);
lcd.write((byte)3);
delay(50);
}
if(digitalRead(A4)){
Ypos=1;
}
if(digitalRead(A5)){
Ypos=0;
lcd.setCursor(Xpos,Ypos);
lcd.write((byte)1);
delay(100);
}
delay(100);
lcd.clear();
}