Stap 2: Arduino Code
float p1;float p2;
zweven del;
float knop;
char importeren;
Boolean spelen;
VOID Setup {}
Serial.begin(9600);
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
pinMode (8, OUTPUT);
pinMode (A2, INPUT);
}
void loop {}
P1 = analogRead(A5);
P2 = analogRead(A0);
Als (analogRead(A2) > = 900) {}
knop = 1;
} else {}
knop = 0;
}
Tekenreeks die wordt verzonden = String(p1) + "" + String(p2) + "" + String(button);
Serial.println(sent);
Als (Serial.available()) {}
importeren = Serial.read();
}
Als (importeren == 1) {}
digitalWrite (2, HIGH);
importeren = 0;
topScore();
}
Als (importeren == 2) {}
digitalWrite (3, hoge);
importeren = 0;
topScore();
}
Als (importeren == 3) {}
digitalWrite (4, HIGH);
importeren = 0;
topWin();
}
Als (importeren == 4) {}
digitalWrite (6, hoge);
importeren = 0;
bottomScore();
}
Als (importeren == 5) {}
digitalWrite (7, hoge);
importeren = 0;
bottomScore();
}
Als (importeren == 6) {}
digitalWrite (8, hoge);
importeren = 0;
bottomWin();
}
Als (importeren == 7) {}
digitalWrite (2, laag);
digitalWrite (3, laag);
digitalWrite (4, laag);
digitalWrite (6, laag);
digitalWrite (7, laag);
digitalWrite (8, laag);
importeren = 0;
}
Als (importeren == 8) {}
Toon (11, 642, 50);
delay(50);
Toon (11 863, 50);
importeren = 0;
}
}
ongeldig topScore() {}
int p [] = {349, 523, 699};
int l [] = {75, 75, 75};
for (int i = 0; ik < 3; i ++) {}
Toon (11 p [i], l[i]);
delay(l[i]);
}
}
ongeldig topWin() {}
int p [] = {349, 349, 523};
int l [] = {200, 300, 500};
for (int i = 0; ik < 3; i ++) {}
Toon (11 p [i], l[i]);
delay(l[i]);
}
}
ongeldig bottomScore() {}
int p [] = {699, 523, 349};
int l [] = {75, 75, 75};
for (int i = 0; ik < 3; i ++) {}
Toon (11 p [i], l[i]);
delay(l[i]);
}
}
ongeldig bottomWin() {}
int p [] = {523, 523, 349};
int l [] = {200, 300, 400};
for (int i = 0; ik < 3; i ++) {}
Toon (11 p [i], l[i]);
delay(l[i]);
}
}