Hello, I'm trying to control the mouse of my pc with an Arduino and a library from Arduino.
Here you can see my code... but when I'm trying to compile this the Arduino IDE gives me this error Message:
In file included from /Users/a_0815_/Documents/Arduino/Fotobox_Arduino/Fotobox_Arduino.ino:1:0:
/Applications/Arduino.app/Contents/Java/libraries/Mouse/src/Mouse.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp] #warning "Using legacy HID core (non pluggable)"
^
/Users/a_0815_/Documents/Arduino/Fotobox_Arduino/Fotobox_Arduino.ino: In function 'void setup()':
Fotobox_Arduino:10:3: error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
Mouse.begin();
^
/Users/a_0815_/Documents/Arduino/Fotobox_Arduino/Fotobox_Arduino.ino: In function 'void loop()':
Fotobox_Arduino:24:5: error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
Mouse.click();
^
exit status 1
'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
The Mouse.h library only works with Arduino models having USB support in the main CPU (p.e. Leonardo, Micro, etc.).
The UNO has a coprocessor for the USB support (ATmega16U2) but is much more difficult to add functionality to it without ruining it's core functionality (loosing the possibility to upload sketches by USB).
For compilation, it's not about which board is connected, it's about which board you have selected from the Arduino IDE's Tools > Board menu. When you compiled that code, you had Tools > Board > Arduino/Genuino Uno selected. If you want to see how it will compile for your Leonardo, you only need to select Tools > Board > Arduino Leonardo before compiling.
lucaswonghellocode:
I tried it. It says about mouse.h
I don't know what you mean by that. If you are getting an error, then you need to post the full error output:
Please do this:
When you encounter an error, you'll see a button on the right side of the orange bar "Copy error messages" in the Arduino IDE (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button..
In a forum reply here, click on the reply field.
Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
Press "Ctrl + V". This will paste the error between the code tags.
Move the cursor outside of the code tags before you add any additional text to your reply.
If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link that will allow you to make the attachment.