Hello,
I am still fairly new to programming and was working on a project where I want to make a shift stick, for games.
So what i did was wrote a piece of code to emulate keys to the computer like i saw on the arduino playground: Keyboard.write() - Arduino Reference
but it doesn't work. So I made a few chages but it still doesn't work, this is the code:
#include <Keyboard.h>
int gear0 = 1;
int gear1 = 2;
int gear2 = 3;
int gear3 = 4;
int gear4 = 5;
int gear5 = 6;
int gear6 = 7;
void setup() {
// put your setup code here, to run once:
pinMode(gear0, INPUT);
pinMode(gear1, INPUT);
pinMode(gear2, INPUT);
pinMode(gear3, INPUT);
pinMode(gear4, INPUT);
pinMode(gear5, INPUT);
pinMode(gear6, INPUT);
Keyboard.begin();
}
void loop() {
if(digitalRead(gear0) == HIGH){
Keyboard.press(0);
delay(500);
}
if(digitalRead(gear1) == HIGH){
Keyboard.press(1);
delay(500);
}
if(digitalRead(gear2) == HIGH){
Keyboard.press(2);
delay(500);
}
if(digitalRead(gear3) == HIGH){
Keyboard.press(3);
delay(500);
}
if(digitalRead(gear4) == HIGH){
Keyboard.press(4);
delay(500);
}
if(digitalRead(gear5) == HIGH){
Keyboard.press(5);
delay(500);
}
if(digitalRead(gear6) == HIGH){
Keyboard.press(6);
delay(500);
}
}
the error i get is
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
If i posted in the wrong section please tell me.
kind regards, Vincent