4 * an arduino sketch to interface with a ps/2 mouse.
\r
5 * Also uses serial protocol to talk back to the host
\r
6 * and report what it finds.
\r
10 * Pin 5 is the mouse data pin, pin 6 is the clock pin
\r
11 * Feel free to use whatever pins are convenient.
\r
16 * initialize the mouse. Reset it, and place it into remote
\r
17 * mode, so we can get the encoder data on demand.
\r
21 mouse.write(0xff); // reset
\r
22 mouse.read(); // ack byte
\r
23 mouse.read(); // blank */
\r
24 mouse.read(); // blank */
\r
25 mouse.write(0xf0); // remote mode
\r
26 mouse.read(); // ack
\r
27 delayMicroseconds(100);
\r
37 * get a reading from the mouse and report it back to the
\r
38 * host via the serial line.
\r
46 /* get a reading from the mouse */
\r
47 mouse.write(0xeb); // give me data!
\r
48 mouse.read(); // ignore ack
\r
49 mstat = mouse.read();
\r
53 /* send the data back up */
\r
54 Serial.print(mstat, BIN);
\r
55 Serial.print("\tX=");
\r
56 Serial.print(mx, DEC);
\r
57 Serial.print("\tY=");
\r
58 Serial.print(my, DEC);
\r
60 // delay(20); /* twiddle */
\r