Arduino test script made

This commit is contained in:
sam
2023-11-21 17:06:03 +01:00
parent 11537bcb46
commit f1cb3bec6f

View File

@@ -0,0 +1,60 @@
const int buttonPinUp = 9; // the number of the pushbutton pin
const int buttonPinRight = 10; // the number of the pushbutton pin
const int buttonPinDown = 11; // the number of the pushbutton pin
const int buttonPinLeft = 12; // the number of the pushbutton pin
const int buttonPinDodge = 14;
const int buttonPinPause = 13;
int buttonStateUp = 0;
int buttonStateDown = 0;
int buttonStateLeft = 0;
int buttonStateRight = 0;
int buttonStateDodge = 0;
int buttonStatePause = 0;
// variables will change:
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPinUp, INPUT);
pinMode(buttonPinRight, INPUT);
pinMode(buttonPinDown, INPUT);
pinMode(buttonPinLeft, INPUT);
pinMode(buttonPinDodge, INPUT);
pinMode(buttonPinPause, INPUT);
Serial.begin(9600);
}
void loop() {
// read the state of the pushbutton value:
buttonStateUp = digitalRead(buttonPinUp);
buttonStateRight = digitalRead(buttonPinRight);
buttonStateDown = digitalRead(buttonPinDown);
buttonStateLeft = digitalRead(buttonPinLeft);
buttonStateDodge = digitalRead(buttonPinDodge);
buttonStatePause = digitalRead(buttonPinPause);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonStateUp == HIGH) {
Serial.println("Up");
}
else if (buttonStateRight == HIGH) {
Serial.println("Right");
}
else if (buttonStateDown == HIGH) {
Serial.println("Down");
}
else if (buttonStateLeft == HIGH) {
Serial.println("Left");
}
else if (buttonStateDodge == HIGH) {
Serial.println("Dodge");
}
else if (buttonStatePause == HIGH) {
Serial.println("Pause");
}
else {
Serial.println("geen button");
}
}