Geting error code when uploading to Arduing Leonardo ??

I am trying to upload this sketch and am getting an error code.
This is the sketch:

//element14 PIK3A Gaming Table Controls, using an Arduino Leonardo//

void setup() {
Keyboard.begin();

//Joystick and buttons pin allocations
pinMode(0, INPUT_PULLUP); //Joystick Up
pinMode(1, INPUT_PULLUP); //Joystick Down
pinMode(2, INPUT_PULLUP); //Joystick Left
pinMode(3, INPUT_PULLUP); //Joystick Right
pinMode(4, INPUT_PULLUP); //button2
pinMode(5, INPUT_PULLUP); //button5
pinMode(6, INPUT_PULLUP); //button3
pinMode(7, INPUT_PULLUP); //player2
pinMode(8, INPUT_PULLUP); //coin
pinMode(9, INPUT_PULLUP); //player1
pinMode(10, INPUT_PULLUP); //button1
pinMode(11, INPUT_PULLUP); //button4
}

void loop() {

// Button labels:
int joystickUp = digitalRead(0);
int joystickDown = digitalRead(1);
int joystickLeft = digitalRead(2);
int joystickRight = digitalRead(3);
int button2 = digitalRead(4);
int button5 = digitalRead(5);
int button3 = digitalRead(6);
int player2 = digitalRead(7);
int coin = digitalRead(8);
int player1 = digitalRead(9);
int button1 = digitalRead(10);
int button4 = digitalRead(11);

// Joystick Up - Arrow Up Key
if (joystickUp == LOW) {
Keyboard.press(218);
}
else {
Keyboard.release(218);
}

// Joystick Down - Arrow Down Key
if (joystickDown == LOW) {
Keyboard.press(217);
}
else {
Keyboard.release(217);
}

// Joystick Left - Arrow Left Key
if (joystickLeft == LOW) {
Keyboard.press(216);
}
else {
Keyboard.release(216);
}

// Joystick Right - Arrow Right Key
if (joystickRight == LOW) {
Keyboard.press(215);
}
else {
Keyboard.release(215);
}

// Button 1 - b
if (button1 == LOW) {
Keyboard.press(98);
}
else {
Keyboard.release(98);
}

// Button 2 - Left ALT
if (button2 == LOW) {
Keyboard.press(130);
}
else {
Keyboard.release(130);
}

// Button 3 - Left CTRL
if (button3 == LOW) {
Keyboard.press(32);
}
else {
Keyboard.release(32);
}

// Button 4 - Left CTRL
if (button4 == LOW) {
Keyboard.press(129);
}
else {
Keyboard.release(129);
}

// Button 5 - Left ALT
if (button5 == LOW) {
Keyboard.press(130);
}
else {
Keyboard.release(130);
}

// Player2 - 2
if (Player2 == LOW) {
Keyboard.press(50);
}
else {
Keyboard.release(50);
}

// Coin - 5
if (coin == LOW) {
Keyboard.press(53);
}
else {
Keyboard.release(53);
}

// Player1 - 1
if (player1 == LOW) {
Keyboard.press(49); delay(100);
}
else {
Keyboard.release(49);
}

}

and this is the error:

C:\Users\Shane\Documents\Arduino\sketch_dec29a\sketch_jan06a\sketch_jan06a\sketch_jan06a\sketch_jan06a.ino: In function 'void setup()':

sketch_jan06a:4:2: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.begin();

^

C:\Users\Shane\Documents\Arduino\sketch_dec29a\sketch_jan06a\sketch_jan06a\sketch_jan06a\sketch_jan06a.ino: In function 'void loop()':

sketch_jan06a:42:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(218);

^

sketch_jan06a:45:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(218);

^

sketch_jan06a:51:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(217);

^

sketch_jan06a:54:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(217);

^

sketch_jan06a:60:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(216);

^

sketch_jan06a:63:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(216);

^

sketch_jan06a:69:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(215);

^

sketch_jan06a:72:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(215);

^

sketch_jan06a:78:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(98);

^

sketch_jan06a:81:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(98);

^

sketch_jan06a:87:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(130);

Anyone know why I am getting this error???

Thanks!!!!

(deleted)

Correct - on the boards menu under Tools, I have selected my Arduino Leonardo board, and I am also connected to the proper Port for communication.

(deleted)

I think I figured it out. Needed to add #include <Keyboard.h> at the top. The sketch uploads with no issues.

For some reason tho my joystick and buttons and the controller isn't responding after uploading tho.

Could the: Tools - Programmer "AVRISP mkII" be the issue maybe? maybe a different programmer ??

I was having communication with the controller to the video game (Raspberry PI), but it all of a sudden stopped and wont respond anymore. Could I have shorted out the board maybe??
I can upload the sketch and my laptop sees the Arduino controller, but that's it tho.

Shanedm1:
Could the: Tools - Programmer "AVRISP mkII" be the issue maybe? maybe a different programmer ??

No. There's no chance it could be the issue. The only time the Tools > Programmer menu selection does anything at all is when you do Tools > Burn Bootloader or Sketch > Upload Using Programmer.

I don't understand why you created a new thread about the "error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?" error when you already made a thread two weeks ago about the exact same error and people explained the problem to you and you used the fix:

You have also been asked multiple times to use code tags (</> button on the toolbar) when you post code on the forum.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is the forum software can interpret parts of your code as markup (for example, the smiley face in your code above), leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar, then you can manually add the code tags:

```
// your code is here
```

Using code tags and other important information is explained in the How to get the best out of this forum guide. Please read it.

This is the code:

//
#include <Keyboard.h>

void setup() {
Keyboard.begin();

//Joystick and buttons pin allocations
pinMode(0, INPUT_PULLUP); //Joystick Up
pinMode(1, INPUT_PULLUP); //Joystick Down
pinMode(2, INPUT_PULLUP); //Joystick Left
pinMode(3, INPUT_PULLUP); //Joystick Right
pinMode(4, INPUT_PULLUP); //button2
pinMode(5, INPUT_PULLUP); //button5
pinMode(6, INPUT_PULLUP); //button3
pinMode(7, INPUT_PULLUP); //player2
pinMode(8, INPUT_PULLUP); //coin
pinMode(9, INPUT_PULLUP); //player1
pinMode(10, INPUT_PULLUP); //button1
pinMode(11, INPUT_PULLUP); //button4
}

void loop() {

// Button labels:
int joystickUp = digitalRead(0);
int joystickDown = digitalRead(1);
int joystickLeft = digitalRead(2);
int joystickRight = digitalRead(3);
int button2 = digitalRead(4);
int button5 = digitalRead(5);
int button3 = digitalRead(6);
int player2 = digitalRead(7);
int coin = digitalRead(8);
int player1 = digitalRead(9);
int button1 = digitalRead(10);
int button4 = digitalRead(11);

// Joystick Up - Arrow Up Key
if (joystickUp == LOW) {
Keyboard.press(218);
}
else {
Keyboard.release(218);
}

// Joystick Down - Arrow Down Key
if (joystickDown == LOW) {
Keyboard.press(217);
}
else {
Keyboard.release(217);
}

// Joystick Left - Arrow Left Key
if (joystickLeft == LOW) {
Keyboard.press(216);
}
else {
Keyboard.release(216);
}

// Joystick Right - Arrow Right Key
if (joystickRight == LOW) {
Keyboard.press(215);
}
else {
Keyboard.release(215);
}

// Button 1 - b
if (button1 == LOW) {
Keyboard.press(98);
}
else {
Keyboard.release(98);
}

// Button 2 - Left ALT
if (button2 == LOW) {
Keyboard.press(130);
}
else {
Keyboard.release(130);
}

// Button 3 - Left CTRL
if (button3 == LOW) {
Keyboard.press(32);
}
else {
Keyboard.release(32);
}

// Button 4 - Left CTRL
if (button4 == LOW) {
Keyboard.press(129);
}
else {
Keyboard.release(129);
}

// Button 5 - Left ALT
if (button5 == LOW) {
Keyboard.press(130);
}
else {
Keyboard.release(130);
}

// player2 - 2
if (player2 == LOW) {
Keyboard.press(50);
}
else {
Keyboard.release(50);
}

// Coin - 5
if (coin == LOW) {
Keyboard.press(53);
}
else {
Keyboard.release(53);
}

// Player1 - 1
if (player1 == LOW) {
Keyboard.press(49); delay(100);
}
else {
Keyboard.release(49);
}

}

Everything uploads fine. But the controller just isn't responding to anything now.
The first obvious thing would be to check my grounds on the switches, and they are all fine.

Maybe I need to reset the controller to factory settings and then upload the sketch ??

You still didn't use code tags!

(deleted)

pert:
You still didn't use code tags!

sorry for the noob questions. I am more up to speed with it all tho.

I really appreciate everyones help.

Thank you!!!!

So my code works perfectly, but I am getting another glitch. When I power down the Raspberry Pi, the controller shuts off at the same time as well, but the problem is when everything is turned back on. When it powers back up, the controller no longer works and I have to upload the sketch again. Is there something I'm missing??

Thanks!

Does pressing the reset button on the Leonardo also make it work?

Yes it does

so it seems I am still having problems with my code:

//Gaming Table Controls, using an Arduino Leonardo//

#include <Keyboard.h>

void setup() {
Keyboard.begin();

//Joystick and buttons pin allocations
pinMode(0, INPUT_PULLUP); //Joystick Up
pinMode(1, INPUT_PULLUP); //Joystick Down
pinMode(2, INPUT_PULLUP); //Joystick Left
pinMode(3, INPUT_PULLUP); //Joystick Right
pinMode(4, INPUT_PULLUP); //Button 1
pinMode(5, INPUT_PULLUP); //Button 2
pinMode(6, INPUT_PULLUP); //Button 3
pinMode(7, INPUT_PULLUP); //Button 4
pinMode(8, INPUT_PULLUP); //Coin
pinMode(9, INPUT_PULLUP); //Start
}

void loop() {

// Button labels:
int joystickUp = digitalRead(0);
int joystickDown = digitalRead(1);
int joystickLeft = digitalRead(2);
int joystickRight = digitalRead(3);
int button1 = digitalRead(4);
int button2 = digitalRead(5);
int button3 = digitalRead(6);
int button4 = digitalRead(7);
int coin = digitalRead(8);
int start = digitalRead(9);

// Joystick Up - Arrow Up Key
if (joystickUp == LOW) {
Keyboard.press(218);
}
else {
Keyboard.release(218);
}

// Joystick Down - Arrow Down Key
if (joystickDown == LOW) {
Keyboard.press(217);
}
else {
Keyboard.release(217);
}

// Joystick Left - Arrow Left Key
if (joystickLeft == LOW) {
Keyboard.press(216);
}
else {
Keyboard.release(216);
}

// Joystick Right - Arrow Right Key
if (joystickRight == LOW) {
Keyboard.press(215);
}
else {
Keyboard.release(215);
}

// Button 1 - Left CTRL
if (button1 == LOW) {
Keyboard.press(128);
}
else {
Keyboard.release(128);
}

// Button 2 - Left ALT
if (button2 == LOW) {
Keyboard.press(130);
}
else {
Keyboard.release(130);
}

// Button 3 - Left CTRL
if (button3 == LOW) {
Keyboard.press(32);
}
else {
Keyboard.release(32);
}

// Button 4 - Left CTRL
if (button4 == LOW) {
Keyboard.press(129);
}
else {
Keyboard.release(129);
}

// Coin - 5
if (coin == LOW) {
Keyboard.press(53);
}
else {
Keyboard.release(53);
}

// Start - 1
if (start == LOW) {
Keyboard.press(49);
}
else {
Keyboard.release(49);
}

}

and here is the error:

In file included from C:\Users\ALT\Desktop\best_sketch_Jan28_2019\best_sketch_Jan28_2019.ino:3:0:

C:\Program Files (x86)\Arduino\libraries\Keyboard\src/Keyboard.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]

#warning "Using legacy HID core (non pluggable)"

^

C:\Users\ALT\Desktop\best_sketch_Jan28_2019\best_sketch_Jan28_2019.ino: In function 'void setup()':

best_sketch_Jan28_2019:6:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.begin();

^

C:\Users\ALT\Desktop\best_sketch_Jan28_2019\best_sketch_Jan28_2019.ino: In function 'void loop()':

best_sketch_Jan28_2019:41:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(218);

^

best_sketch_Jan28_2019:44:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(218);

^

best_sketch_Jan28_2019:50:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(217);

^

best_sketch_Jan28_2019:53:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(217);

^

best_sketch_Jan28_2019:59:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(216);

^

best_sketch_Jan28_2019:62:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(216);

^

best_sketch_Jan28_2019:68:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(215);

^

best_sketch_Jan28_2019:71:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(215);

^

best_sketch_Jan28_2019:77:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(128);

^

best_sketch_Jan28_2019:80:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(128);

^

best_sketch_Jan28_2019:86:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(130);

^

best_sketch_Jan28_2019:89:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(130);

^

best_sketch_Jan28_2019:95:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(32);

^

best_sketch_Jan28_2019:98:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(32);

^

best_sketch_Jan28_2019:104:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(129);

^

best_sketch_Jan28_2019:107:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(129);

^

best_sketch_Jan28_2019:113:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(53);

^

best_sketch_Jan28_2019:116:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(53);

^

best_sketch_Jan28_2019:122:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(49);

^

best_sketch_Jan28_2019:125:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(49);

^

exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

Any suggestions??

Thanks!

Still not using code tags! People on this forum have made a lot of effort to help you for free, yet you won't take a second to make our job easier. That doesn't seem very respectful.

You need to select Tools > Board > Arduino Leonardo.