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!!!!