esp32S2 HID keyboard
Posted: Wed Dec 30, 2020 11:09 pm
Very simple example of USB HID keyboard with saola board and m5stack cardKB. Code will be available on arduino and is very simple and easy to use:
Code: Select all
#include "hidkeyboard.h"
#include "Wire.h"
#define KEYBOARD_I2C_ADDR 0X5f
HIDkeyboard dev;
void setup()
{
Serial.begin(115200);
Wire.begin(7,8);
dev.begin();
}
void loop()
{
delay(10);
Wire.requestFrom(KEYBOARD_I2C_ADDR, 1); // request 1 byte from keyboard
while (Wire.available()) {
uint8_t key_val = Wire.read(); // receive a byte as character
if(key_val != 0) {
dev.sendChar(key_val); // send ASCII char
}
}
}