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;
#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.