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
|
int LED_ROUGE = 2;
int LED_ORANGE = 3;
int LED_VERTE = 4;
int BOUTON_GAUCHE = 8;
int BOUTON_DROITE = 11;
int BOUTON_BAS = 10;
int BOUTON_HAUT = 9;
int BOUTON_VAL = 12;
int ETAT_BOUTON_GAUCHE;
int ETAT_BOUTON_DROITE;
int ETAT_BOUTON_HAUT;
int ETAT_BOUTON_BAS;
int ETAT_BOUTON_VAL;
void setup()
{
Serial.begin(9600);
pinMode(LED_ROUGE, OUTPUT);
pinMode(LED_VERTE, OUTPUT);
pinMode(LED_ORANGE, OUTPUT);
pinMode(BOUTON_GAUCHE, INPUT);
pinMode(BOUTON_DROITE, INPUT);
pinMode(BOUTON_BAS, INPUT);
pinMode(BOUTON_HAUT, INPUT);
pinMode(BOUTON_VAL, INPUT);
}
void loop()
{
ETAT_BOUTON_GAUCHE = digitalRead(BOUTON_GAUCHE);
if (ETAT_BOUTON_GAUCHE == 0)
{
digitalWrite(LED_VERTE, 1);
Serial.print("BTG");
Serial.print(1);
Serial.print(";");
delay(500);
}
else
{
digitalWrite(LED_VERTE, 0);
Serial.print("BTG");
Serial.print(0);
Serial.print(";");
}
ETAT_BOUTON_DROITE = digitalRead(BOUTON_DROITE);
if (ETAT_BOUTON_DROITE == 0)
{
digitalWrite(LED_ORANGE, 1);
Serial.print("BTD");
Serial.print(1);
Serial.print(";");
delay(500);
}
else
{
digitalWrite(LED_ORANGE, 0);
Serial.print("BTD");
Serial.print(0);
Serial.print(";");
}
ETAT_BOUTON_BAS = digitalRead(BOUTON_BAS);
if (ETAT_BOUTON_BAS == 0)
{
digitalWrite(LED_ROUGE, 1);
Serial.print("BTB");
Serial.print(1);
Serial.print(";");
delay(500);
}
else
{
digitalWrite(LED_ROUGE, 0);
Serial.print("BTB");
Serial.print(0);
Serial.print(";");
}
ETAT_BOUTON_HAUT = digitalRead(BOUTON_HAUT);
if (ETAT_BOUTON_HAUT == 0)
{
digitalWrite(LED_ROUGE, 1);
Serial.print("BTH");
Serial.print(1);
Serial.print(";");
delay(500);
}
else
{
digitalWrite(LED_ROUGE, 0);
Serial.print("BTH");
Serial.print(0);
Serial.print(";");
}
ETAT_BOUTON_VAL = digitalRead(BOUTON_VAL);
if (ETAT_BOUTON_VAL == 0)
{
digitalWrite(LED_ROUGE, 1);
Serial.print("BTV");
Serial.print(1);
Serial.println(";");
delay(500);
}
else
{
digitalWrite(LED_ROUGE, 0);
Serial.print("BTV");
Serial.print(0);
Serial.println(";");
}
}
|