Hello!
I am currently working on a project that entails using a Arduino as a mouse. In the code posted, I am trying to get the cursor of the mouse to move when a certain keyboard button is pressed by reading inputs from the serial monitor.
For this project I am using the Arduino Leonardo (which after a bit of research saw is compatible with the Arduino mouse library).
My code will not compile, I am receiving the following error message:
error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
Mouse.end();
^~~~~
Multiple libraries were found for "Mouse.h"
The code I have written is below. I have included the header file, so I am a bit confused on why I keep getting this problem. Any help is appreciated, thanks!
P.S. Haven't had a chance to debug the rest of the code yet (stuck on the dang header file problem), so there might be other errors that I haven't picked up on yet.
#include <Mouse.h>
void setup() {
Mouse.begin();
}
void loop() {
if(Serial.available()){
direction = Serial.read();
if(direction == 'w'){
Mouse.move(0, 10, 0);
}
else if(direction == 'd'){
Mouse.move(10, 0, 0);
}
else if(direction == 's'){
Mouse.move(0, -10, 0);
}
else if(direction == 'a'){
Mouse.move(-10, 0, 0);
}
else if(direction == 'h'){
Mouse.move(0, 0, 10);
}
else if(direction == 'j'){
Mouse.move(0, 0, -10);
}
else if(direction == 'k'){
Mouse.click();
}
else if(direction == 'L'){
Mouse.click(MOUSE_RIGHT);
}
else if(direction == 'E'){
Mouse.end();
}
}
}