]> git.piffa.net Git - arduino/blob - books/ArduinoNextSteps-master/ArduinoNextSteps/sketch_11_06_mouse_due/sketch_11_06_mouse_due.ino
first commit
[arduino] / books / ArduinoNextSteps-master / ArduinoNextSteps / sketch_11_06_mouse_due / sketch_11_06_mouse_due.ino
1 // sketch_11_06_mouse_due
2
3 #include <MouseController.h>
4
5 USBHost usb;
6 MouseController mouse(usb);
7
8 void setup()
9 {
10   Serial.begin(9600);
11   Serial.println("Program started");
12   delay(200);
13 }
14
15 void loop()
16 {
17   usb.Task();
18 }
19
20 // This function intercepts mouse movements
21 void mouseMoved() 
22 {
23   int x = mouse.getXChange();
24   int y = mouse.getYChange();
25   if (x > 50) Serial.print("R");
26   if (x < -50) Serial.print("L");
27   if (y > 50) Serial.print("D");
28   if (y < -50) Serial.print("U");  
29 }