Skip to content

Instantly share code, notes, and snippets.

@dkgrieshammer
Created November 26, 2018 20:23
Show Gist options
  • Save dkgrieshammer/39f2417d0088f9440c1d19183a220b5b to your computer and use it in GitHub Desktop.
Save dkgrieshammer/39f2417d0088f9440c1d19183a220b5b to your computer and use it in GitHub Desktop.
Nextion Display on Arduino Micro as Keyboard Input :)
#include <SoftwareSerial.h>
#include "Keyboard.h"
SoftwareSerial mySerial(9, 10); // RX, TX
void setup() {
Serial.begin(9600);
// Serial1.begin(9600);
mySerial.begin(9600);
Keyboard.begin();
}
void loop() {
// if(Serial.available()) {
// Keyboard.print("T");
// }
if(mySerial.available()) {
byte tmp = mySerial.read();
Serial.write(tmp);
delay(100);
// Keyboard.print(tmp);
// back
if( tmp == 'b') {
Keyboard.print("n");
}
// right
if( tmp == 'n') {
Keyboard.print("e");
}
// up
if( tmp == 'u') {
Keyboard.print("m");
}
// down
if( tmp == 'd') {
Keyboard.print("k");
}
// ok
if( tmp == 'o') {
Keyboard.print("l");
}
// assist
if( tmp == 'a') {
// Keyboard.print("m");
}
// call
if( tmp == 'c') {
// Keyboard.print("m");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment