Problems including mouse.h

I'm new to C++ but I'm learning fast. I'm writing a quick exercise that will use the mouse when the light is at a certain level. I'm getting an error saying that I don't have the Mouse.h in my sketch. I'm pretty sure I included it properly and I've checked my libraries to make sure that it exists.

#include <Mouse.h>

int photocellPin = 1;     // the cell and 10K pulldown are connected to a0
int photocellReading;     // the analog reading from the analog resistor divider
 
void setup(void) {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);
  Mouse.begin();  
}
 
void loop(void) {
  photocellReading = analogRead(photocellPin);  
 
  Serial.print("Analog reading = ");
  Serial.print(photocellReading);     // the raw analog reading
 
  // We'll have a few threshholds, qualitatively determined
  if (photocellReading < 10) {
    Serial.println(" - Dark");
  } else if (photocellReading < 200) {
    Serial.println(" - Dim");
  } else if (photocellReading < 500) {
    Serial.println(" - Light");
  } else if (photocellReading < 800) {
    Serial.println(" - Bright");
  } else {
    Serial.println(" - Very bright");
  }
  checkScreen();
  delay(200);
}

void checkScreen()
{
  int cellVal = analogRead(23);
  if(cellVal >= 50)
  {
    Mouse.begin();
    Mouse.click();
    delay(1500);
    Mouse.end();
  }
}

I'm sure there are many problems with my sketch as I'm splicing together pieces of other sketches but I'm looking for a solution to the error I'm getting. Any other input is welcome but not necessary.

Here's the error report

Arduino: 1.6.6 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Users\####\Documents\Arduino\sketch_nov28b\sketch_nov28b.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mouse\src/Mouse.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]

 #warning "Using legacy HID core (non pluggable)"

  ^

C:\Users\####\Documents\Arduino\sketch_nov28b\sketch_nov28b.ino: In function 'void setup()':

sketch_nov28b:9: error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
   Mouse.begin();  

   ^

C:\Users\####\Documents\Arduino\sketch_nov28b\sketch_nov28b.ino: In function 'void checkScreen()':

sketch_nov28b:39: error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
     Mouse.begin();

     ^

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

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
1 Like

The UNO is NOT a Mouse. It is pointless to try to make it one.

I'm sorry that you misunderstood the topic. I am not asking for opinions on the use of my UNO. I'm asking for help on using the mouse functionality of it, purely as a learning experience. I do not intend to use my UNO as a mouse, because that is what my mouse is for.

1 Like

Thank you Delta_G for clearing it up for me

More like the first line of the third paragraph.

It's funny, because I googled this very same topic, and this was the first link on the results, not the docs.

So, thank you Silentrizz for asking the right question.