-
Notifications
You must be signed in to change notification settings - Fork 0
/
JuegPong.ino
53 lines (41 loc) · 927 Bytes
/
JuegPong.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
const int ledCount = 5;
int ledPins[] = {2, 3, 4, 5, 6};
int buttonR = 9;
int buttonL = 10;
int ledDelay = 100;
void setup() {
for (int i=0;i<ledCount;i++)
pinMode(ledPins[i], OUTPUT);
pinMode(buttonR, INPUT);
pinMode(buttonL, INPUT);
}
void loop() {
for (int count=6;count>1;count--) {
if (count == 2 && digitalRead(buttonR) == LOW) {
gameOver();
}
digitalWrite(count, HIGH);
delay(ledDelay);
digitalWrite(count, LOW);
}
for (int count=2;count<7;count++) {
if (count == 6 && digitalRead(buttonL) == LOW) {
gameOver();
}
digitalWrite(count, HIGH);
delay(ledDelay);
digitalWrite(count, LOW);
}
}
void gameOver() {
for (int i=0;i<10;i++) {
for (int count=2;count<7;count++) {
digitalWrite(count, HIGH);
}
delay(ledDelay);
for (int count=2;count<7;count++) {
digitalWrite(count, LOW);
}
delay(ledDelay);
}
}