D
D
DimiDr0lik2015-05-20 17:22:20
Arduino
DimiDr0lik, 2015-05-20 17:22:20

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

3 answer(s)
U
user 8128, 2015-05-21
@ErvinM

habrahabr.ru/post/240291
habrahabr.ru/post/250347

A
Alexander Volkov, 2015-11-03
@a_volkov1987

Use codes 79 and 80 for the right arrow and left arrow keys, respectively.

U
unicorn791, 2020-11-04
@unicorn791

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 question

Ask a Question

731 491 924 answers to any question