I am trying to get a response from the arduino when I press a key, but when I try to upload the code it says that it could not find 'Keyboard' with 'Keyboard.write'. Here is my code. Ignore the bits with servo stuff, that is for the project later on. I am using the arduino mega 2560.
#include <Servo.h>
#include <Keyboard.h>
Servo myservo;
Servo myservo2;
int pos = 0;
int pos2 = 0;
String comdata = "";
int lastLength = 0;
void setup() {
myservo.attach(12);
myservo2.attach(11);
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
if (Serial.available() > 0) {
// read incoming serial data:
char inChar = Serial.read();
Keyboard.write(inChar + 1);
}
}