1

This is my first script written with Arduino. I wrote a simple Hello World program but I'm getting the following error.

Test:18: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
   Keyboard.begin();
   ^
exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

Here is the code:

#include "Keyboard.h"

void typeKey(int key)
{
  Keyboard.press(key);
  delay(50);
  Keyboard.release(key);
}

void setup()
{
  // Begining the Keyboard stream
  Keyboard.begin();

  // Wait 500ms
  delay(500);

  delay(400);

  Keyboard.print("Hello World!");

  // Ending stream
  Keyboard.end();
}

void loop() {}

I have Arduino/Genuino UNO selected as my board on the IDE. Any suggestions on how I can fix this? Thanks

  • Are there tutorials with the same board? Have you tried code that is verified to be working on other boards (from other tutorials)? – Paul Nov 17 '16 at 16:59
4

Based on the documentation :

These core libraries allow a 32u4 based boards or Due and Zero board to appear as a native Mouse and/or Keyboard to a connected computer.

Core libraries (such as Keyboard.h) are not availabe if your board doesn't mentioned.

I don't know which one is right, since your question title mentioned "Arduino Micro" while at the end of your question, the board is "Arduino Uno".

Just for further information, Arduino Uno is based on - ATmega328P, and Arduino Micro is based on - ATmega32U4. So sure, that "hello world" program will works on Arduino Micro, but not on Arduino Uno.

  • On the Arduino Get Started Page it says for the Arduino Micro in order to program it I need to select Arduino/Genuino UNO as my board thats why I added it at the end. My actual device is the Arduino Micro – Katz Nov 17 '16 at 2:22
  • 1
    Well, how about look at this "Get Started Page" instead : arduino.cc/en/Guide/ArduinoLeonardoMicro go to Select your board parts, and have fun – dhimaspw Nov 17 '16 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.