I want to make a Button box along with the joystick, but for the button box, i would like to add certain code to certain amount of pins (i.e if statement for turning on an LED when the button is HIGH etc) However, when i checked the code, I don't exactly understand how to digital pins are "read" and send to xplane
for (int i = 2; i < 54; i++){
controllerData.buttonArray[(i - 2) / 8] |= (!digitalRead(i)) << ((i - 2) % 8);
}
Is there another way to read from the digital pins where I can add some code to each pin
I saw on the unojoy code that this was possible, but idk how to do this on the megajoy
(this is regarding megajoy)
And also if anyone could explain, why is the button in an array?
I want to make a Button box along with the joystick, but for the button box, i would like to add certain code to certain amount of pins (i.e if statement for turning on an LED when the button is HIGH etc) However, when i checked the code, I don't exactly understand how to digital pins are "read" and send to xplane
for (int i = 2; i < 54; i++){
controllerData.buttonArray[(i - 2) / 8] |= (!digitalRead(i)) << ((i - 2) % 8);
}
Is there another way to read from the digital pins where I can add some code to each pin
I saw on the unojoy code that this was possible, but idk how to do this on the megajoy
(this is regarding megajoy)
And also if anyone could explain, why is the button in an array?