output gets put in booleans and send in array
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <ArduinoJson.hpp>
|
||||
|
||||
const int buttonPinUp = 9; // the number of the pushbutton pin
|
||||
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 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 buttonStateRight = 0;
|
||||
int buttonStateDown = 0;
|
||||
int buttonStateLeft = 0;
|
||||
int buttonStateRight = 0;
|
||||
int buttonStateDodge = 0;
|
||||
int buttonStatePause = 0;
|
||||
bool boolUp = false;
|
||||
bool boolRight = false;
|
||||
bool boolDown = false;
|
||||
bool boolLeft = false;
|
||||
bool boolDodge = false;
|
||||
bool boolPause = false;
|
||||
|
||||
// variables will change:
|
||||
|
||||
@@ -23,10 +31,15 @@ void setup() {
|
||||
pinMode(buttonPinDodge, INPUT);
|
||||
pinMode(buttonPinPause, INPUT);
|
||||
Serial.begin(9600);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
boolUp = false;
|
||||
boolRight = false;
|
||||
boolDown = false;
|
||||
boolLeft = false;
|
||||
boolDodge = false;
|
||||
boolPause = false;
|
||||
// read the state of the pushbutton value:
|
||||
buttonStateUp = digitalRead(buttonPinUp);
|
||||
buttonStateRight = digitalRead(buttonPinRight);
|
||||
@@ -37,24 +50,27 @@ void loop() {
|
||||
|
||||
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
|
||||
if (buttonStateUp == HIGH) {
|
||||
Serial.println("Up");
|
||||
boolUp = true;
|
||||
}
|
||||
else if (buttonStateRight == HIGH) {
|
||||
Serial.println("Right");
|
||||
if (buttonStateRight == HIGH) {
|
||||
boolRight = true;
|
||||
}
|
||||
else if (buttonStateDown == HIGH) {
|
||||
Serial.println("Down");
|
||||
if (buttonStateDown == HIGH) {
|
||||
boolDown = true;
|
||||
}
|
||||
else if (buttonStateLeft == HIGH) {
|
||||
Serial.println("Left");
|
||||
if (buttonStateLeft == HIGH) {
|
||||
boolLeft = true;
|
||||
}
|
||||
else if (buttonStateDodge == HIGH) {
|
||||
Serial.println("Dodge");
|
||||
if (buttonStateDodge == HIGH) {
|
||||
boolDodge = true;
|
||||
}
|
||||
else if (buttonStatePause == HIGH) {
|
||||
Serial.println("Pause");
|
||||
if (buttonStatePause == HIGH) {
|
||||
boolPause = true;
|
||||
}
|
||||
else {
|
||||
Serial.println("geen button");
|
||||
|
||||
String inputOutput = String("[") + boolUp + "," + boolRight + "," + boolDown + "," + boolLeft + "," + boolDodge + "," + boolPause + "]\n";
|
||||
|
||||
if (inputOutput) {
|
||||
Serial.println(inputOutput);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user