-
Notifications
You must be signed in to change notification settings - Fork 1
/
afficheur_simple.ino
127 lines (101 loc) · 1.97 KB
/
afficheur_simple.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
// Buttons states
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
// Compteur
int ValeurSEG = 0;
// Digit
int A = 11;
int B = 10;
int C = 9;
int D = 8;
// Leds :
// Vert
int bled1 = 7;
// Orange
int bled2 = 6;
// Rouge
int bled3 = 5;
// Boutons :
// Valider
int b1 = 4;
// Moins
int b2 = 3;
// Plus
int b3 = 2;
// Good anwser
int PASSWORD = 2 ;
void setup()
{
// Declare all the pins as OUTPUT pins
// Button
pinMode(b1, OUTPUT);
pinMode(b2, OUTPUT);
pinMode(b3, OUTPUT);
// Leds
pinMode(bled1, OUTPUT);
pinMode(bled2, OUTPUT);
pinMode(bled3, OUTPUT);
// Digit Screen
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// read the state of the pushbutton value:
buttonState1 = digitalRead(b1);
buttonState2 = digitalRead(b2);
buttonState3 = digitalRead(b3);
// Check if button if checked
// Valider
if (buttonState1 == HIGH){
if ( ValeurSEG == PASSWORD ) {
digitalWrite(bled1, HIGH);
delay (10000);
digitalWrite(bled1, LOW);
} else {
digitalWrite(bled3, HIGH);
delay (10000);
digitalWrite(bled3, LOW);
}
}
// Moins
if (buttonState2 == HIGH){
ValeurSEG -- ;
}
// Plus
if (buttonState3 == HIGH){
ValeurSEG ++ ;
}
// Create Digit Display
if (ValeurSEG == 0) {
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000) ;
}
if (ValeurSEG == 1) {
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000) ;
}
if (ValeurSEG == 2) {
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000) ;
}
if (ValeurSEG == 3) {
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000) ;
}
}