Thursday 6 March 2014

Quick Update

This is some code for an Arduino Leonardo that will receive character data from the serial pins, then echo the character through USB as keyboard input to the PC.
This will form the basis of a bigger project that'll be the subject of another post, but for now, here's the code:


void setup() {
  Serial1.begin(115200);
  Keyboard.begin();
}

void loop() {
  if (Serial1.available() > 0) {
    byte inChar = Serial1.read();
    Keyboard.write(inChar);
    Serial1.write(inChar);
    delay(10);
  }
}

No comments:

Post a Comment