Keyboard input with arduino?

edited April 2014 in Arduino

Basically I want to have a button connected to arduino and when pressed I want it to be as if "A" was pressed on the keyboard. The code I got so far:

void setup() {
  pinMode(4, INPUT);
  Keyboard.begin();
}

void loop() {
  if (digitalRead(4) == HIGH) {
    Keyboard.write(65);
  }
  else {
    Keyboard.write(0);
  }
  delay(100);
}

Now when I verify it, there's no error. When I upload it however, I get the message that Keyboard is only available on Arduino Leonardo (I bought UNO). So I'm wondering if the code like this would work on a Leonardo or if the code is totally wrong?

Tagged:

Answers

Sign In or Register to comment.