Answer the question
In order to leave comments, you need to log in
Keyboard emulator on arduino?
Hello people.
There is a task to emulate the keyboard on arduino, there was a problem, when transferring the key code, the wrong keys are emulated.
the routine I use to pass the keyCode is:
void pressKey(int dig) // Input function
{
buf[2] = dig;
Serial.write(buf, 8); // Press key
buf[0] = 0;
buf[2] = 0;
delay(20);
Serial.write(buf, 8); // Release key
delay(200);
}
I pass 37 (left arrow) and 39 (right) to dig, and the characters "0" and "8" are transmitted
Answer the question
In order to leave comments, you need to log in
Use codes 79 and 80 for the right arrow and left arrow keys, respectively.
For such actions, it is easier to use a board specially designed for this purpose, namely the Arduino Leonardo, and such problems will disappear.
An example of the implementation of this + control via Ethernet Shield is the usb2kbd project ( usb2kbd.ru ).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question