"'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?"

Im new to Arduino, and i have recently wanted to make the joystick that comes with the Plusivo kit (Yes its not an Arduino product , but it has the same capabilities as an Arduino, it even uses the same text editor in which case is "Arduino IDE" ) and turn it into a mouse sort of thing .
This is my code:

#include <Mouse.h>

const int switchPin = 2;
const int mouseButton = 3;
const int xAxis = A0;
const int yAxis = A1;
const int ledPin = 5;

int range = 12;
int responseDelay = 5;
int threshold = range / 4;
int center = range / 2;

bool mouseIsActive = false;
int lastSwitchState = LOW;

void setup() {

pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
Mouse.begin();

}

void loop() {

// put your main code here, to run repeatedly:

}

The error is :Compilation error: "'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?"
The code is not yet finished as you can see , but thats not the problem .
The problem is that why cant i use "Mouse" if the library is included ? If its an easy solution please tell me.

What is your board?

Welcome to the forum

Which board have you got selected in the IDE ?
Where did you get the code ?

You will need to install the Mouse library. In the Arduino IDE, go to Tools -> Manage Libraries, and do a search for "mouse". It should list Mouse by Arduino, click "Install".

2023-11-01 15_16_22-Window

Hello.
Thanks for replying .
When i look at my board , it just says Plusivo , no exact name . Ive also looked at the website of the creators of the board , and it says its called just "Plusivo Microcontroller Board"

Hello.

Thank you Benjamin , i have not realise how dumb i am . I thought the library was pre-installed. :slight_smile:

For anyone interested, it appears that the Plusivio is an Uno R3

https://www.plusivo.ph/all-products/8-uno-r3-development-board-atmega328p-atmega16u2-50-cm-cable.html

But what board did you selected in the IDE when you try to compile the code?

The board has to be of the correct type

From Mouse - Arduino Reference

The mouse functions enable 32u4 or SAMD micro based boards to control cursor movement on a connected computer through their micro’s native USB port.

This is why I asked what the board was set to in the IDE

Uno R3 is not compatible with Mouse library

It just says its an "Arduino Uno"

image

This is the kit that i bought :

Its just called Plusivo for some reason.

No, this won't help to compile the code for Uno board. The library is not compatible with Uno.
You need a board with native USB support, for example Arduino Micro

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.