I am trying to make a button box keyboard with an Arduino Nano, but IDE seems to be unable to recognize the commands for the library. It doesn't generate and error for the "#include <Keyboard.h>", only for the attempts to use functions from the library. The file location is set correctly in preferences and the library is downloaded, I have tried redownloading it by several methods, nothing has worked. please help.
Error code:
F:\4 - Projects\DEWYED\PE Electronics\PE 100 Arduino\PE 110 Sketches\PE 111 Keyboard\sketch_jul10a\sketch_jul10a.ino: In function 'void setup()':
F:\4 - Projects\DEWYED\PE Electronics\PE 100 Arduino\PE 110 Sketches\PE 111 Keyboard\sketch_jul10a\sketch_jul10a.ino:16:1: error: 'Keyboard' was not declared in this scope
Keyboard.begin();
^~
F:\4 - Projects\DEWYED\PE Electronics\PE 100 Arduino\PE 110 Sketches\PE 111 Keyboard\sketch_jul10a\sketch_jul10a.ino: In function 'void loop()':
F:\4 - Projects\DEWYED\PE Electronics\PE 100 Arduino\PE 110 Sketches\PE 111 Keyboard\sketch_jul10a\sketch_jul10a.ino:24:5: error: 'Keyboard' was not declared in this scope
Keyboard.write('A'); //Sending the "A" character
^~
exit status 1
Compilation error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h
My code:
#include <Keyboard.h>
int pinA = 2; //Declaring variables for the pins
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
void setup() {
pinMode(pinA, INPUT_PULLUP); //Setting up the internal pull-ups resistors
pinMode(pinB, INPUT_PULLUP); //and also setting the pins to inputs.
pinMode(pinC, INPUT_PULLUP);
pinMode(pinD, INPUT_PULLUP);
pinMode(pinE, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
if (digitalRead(pinA) == LOW) //Checking if the first switch has been pressed
{
Keyboard.write('A'); //Sending the "A" character
delay(500);
}
}
If this is in the wrong category let me know.