mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 21:10:58 +02:00
Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com> Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com> Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com> Co-authored-by: Ivan Grokhotkov <ivan@espressif.com> Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
47 lines
999 B
C++
47 lines
999 B
C++
/*
|
|
Keyboard test
|
|
|
|
Reads a byte from the serial port, sends a keystroke back.
|
|
The sent keystroke is one higher than what's received, e.g. if you send a,
|
|
you get b, send A you get B, and so forth.
|
|
|
|
The circuit:
|
|
- none
|
|
|
|
created 21 Oct 2011
|
|
modified 27 Mar 2012
|
|
by Tom Igoe
|
|
|
|
This example code is in the public domain.
|
|
|
|
http://www.arduino.cc/en/Tutorial/KeyboardSerial
|
|
*/
|
|
#if ARDUINO_USB_MODE
|
|
#warning This sketch should be used when USB is in OTG mode
|
|
void setup(){}
|
|
void loop(){}
|
|
#else
|
|
|
|
#include "USB.h"
|
|
#include "USBHIDKeyboard.h"
|
|
USBHIDKeyboard Keyboard;
|
|
|
|
void setup() {
|
|
// open the serial port:
|
|
Serial.begin(115200);
|
|
// initialize control over the keyboard:
|
|
Keyboard.begin();
|
|
USB.begin();
|
|
}
|
|
|
|
void loop() {
|
|
// check for incoming serial data:
|
|
if (Serial.available() > 0) {
|
|
// read incoming serial data:
|
|
char inChar = Serial.read();
|
|
// Type the next ASCII value from what you received:
|
|
Keyboard.write(inChar + 1);
|
|
}
|
|
}
|
|
#endif /* ARDUINO_USB_MODE */
|