Hello everyone,
i start with the premise that it is the first time i take an arduino in hand, but i have knowledge of other programming languages. at the suggestion of a friend of mine who tried every now and then to do some small projects with arduino, i bought a nano.
I have a numpad(17 keys), which i would like to turn into a sort of macro keyboard (hid macros and other software do not meet my requirements).
With the help of my friend i cut the usb(usb A, i think 1.0) cable and it divided in 4 cables:
red 5v, black g, white d + and green d-
For the correspondence of the wires i based myself on what is written next to the welding on the chip.
So i connected red and black in their respective pins and then the white on d2 and green on d3.
At this point we wrote a small code just to find out what input the keyboard sent, and then begin to create the bindings of the keys
int testo;
int testo2;
void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(3, INPUT);
}
void loop() {
testo = digitalRead(2);
testo2 = digitalRead(3);
delay(1000);
Serial.write(testo);
Serial.write("...");
Serial.write(testo2);
}
Unfortunately, however, when i compile the arduino, on the serial monitor i have this output:
which continues to infinity even if i try to click any key on the numpad.
did i miss anything in the cable connection or in the code?