// including keyboard n setting up pins + state #include <Keyboard.h>
int state = digitalRead(2 & 4);
int state2 = digitalRead(3 & 4);
int state3 = digitalRead(5 & 2);
int state4 = digitalRead(5 & 3);
void setup() {
pins();
Keyboard.begin();
}
And don't forget to format it using the 'auto format' tool in the Arduino IDE.
What is this meant to do? & is the bitwise "and" operator... I have no idea what you're planning to use it for here.
You must always put parentheses at the end of a function call regardless of whether or not the function actually takes in arguments, so w; should be w();... etc.
I would advise against this... just put the pinMode()s in the setup. There is no enclosing function necessary for them, especially since you're only using 4 pins.
While this isn't (strictly) a problem, I hope that you realize that you're not actually dynamically checking for an updated state, since you're not calling digitalRead() to update the state in the loop... you put that at the top of your sketch instead (yes, this should be inside your loop ). Additionally, digitalRead() returns a boolean, so it might be a good idea to make your states type bool instead. This goes for each state variable function.
int state = digitalRead(2 & 4);
int state2 = digitalRead(3 & 4);
int state3 = digitalRead(5 & 2);
int state4 = digitalRead(5 & 3);
The & does a bitwise AND of the two numbers, resulting in the first three statements reading port 0, the last statement reads port 1. This sets the initial value of the four variables, which will remain this value forever because you never change any of them anywhere in the code. These digitalReads are executed BEFORE setup() runs.
the & is used in my code (Im guessing it works like that, i dont really know) to register a button press when two pins are "HIGH" or on.
4...5
2w...a
3 s...d
Ok i think i fixed it...
// including keyboard n setting up pins + state #include <Keyboard.h>
int state, state2, state3, state4;
void setup() {
pins();
Keyboard.begin();
}