Go Down

Topic: Arduino Keyboard Library Problem (Read 158 times) previous topic - next topic


I have been looking at making some custom controllers for my PC and wanted to use the built in Keyboard and Mouse library to do it. The problem though is I keep getting the same error message when I start using the code:

error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

I don't think my code is the issue;
Code: [Select]
#include <Keyboard.h>                  //Adding the keyboard library

int shaker = 7;                        //Declaring the pin for the vibration sensor

void setup()
  pinMode(shaker, INPUT);              //Declaring the senor pin
  Keyboard.begin();                    //intializing control over keyboard

void loop()
  int val = digitalRead(shaker);       //Collecting sensor stat, works as a button

  if(val == HIGH)                      //Test sensor stat
    Keyboard.press('w');               //pressing keyboard key 'w'
    Keyboard.releaseAll();             //inputing the pressed key

I tried re downloading the keyboard library but then I just got another error that said there were multiply versions of that library. I have seen other people have had this issue but the only other post I found on the topic on the forum did not have a solution.

Any help would be greatly appreciated. 


What type of Arduino are you using?
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.


Reply #2 in the thread that you linked probably contains the answer ;)
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.


Reply #2 in the thread that you linked probably contains the answer ;)
Ah your right, I thought I heard all the libraries in the Arduino IDE work with the Arduino Uno. Apparently after doing some more digging you need a board based off of 32u4 or SAMD (Leonardo, Esplora, Zero, Due and MKR Family). Thanks for your help.  

Go Up