So I am trying to make a two keys keyboard with an arduino uno, but an error pops up and I think my code is ok. Could someone help me please?
code I use:
#include<Keyboard.h>
const int led1 = 5;
const int led2 = 4;
const int buttonX = 3;
const int buttonZ = 2;
void setup()
{
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(buttonX, INPUT);
pinMode(buttonZ, INPUT);
#include<Keyboard.h>
const int led1 = 5;
const int led2 = 4;
const int buttonX = 3;
const int buttonZ = 2;
Keyboard.begin();
}
void loop()
{
if (digitalRead(buttonX) == LOW)
{
Keyboard.press('x');
digitalWrite(led1, HIGH);
}
else
{
Keyboard.release('x');
digitalWrite(led1, LOW);
}
if (digitalRead(buttonZ) == LOW)
{
Keyboard.press('z');
digitalWrite(led2, HIGH);
}
else
{
Keyboard.release('z');
digitalWrite(led2, LOW);
}
}
error I get:
Arduino: 1.8.5 (Mac OS X), Board: "Arduino/Genuino Uno"
Build options changed, rebuilding all
In file included from /Users/aaron/Documents/Arduino/osu_keyboard/osu_keyboard.ino:27:0:
/Users/aaron/Desktop/Arduino.app/Contents/Java/libraries/Keyboard/src/Keyboard.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]
#warning "Using legacy HID core (non pluggable)"
^
/Users/aaron/Documents/Arduino/osu_keyboard/osu_keyboard.ino: In function 'void setup()':
osu_keyboard:47: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.begin(); //This allows control over the keyboard.
^
/Users/aaron/Documents/Arduino/osu_keyboard/osu_keyboard.ino: In function 'void loop()':
osu_keyboard:54: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press('x'); //press the 'x' key.
^
osu_keyboard:60: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release('x'); //release the 'x' key.
^
osu_keyboard:67: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press('z'); //press the 'z' key.
^
osu_keyboard:73: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release('z'); //release the 'z' key.
^
exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
osu_keyboard.ino (2.54 KB)