Dwayne Dilbeck
/
HW2_3_USB_POT_Mouse
Homework #2 Problem #3
Fork of USBMouse_HelloWorld by
main.cpp
- Committer:
- jakowisp
- Date:
- 2013-06-26
- Revision:
- 5:2a28b4664b0a
- Parent:
- 3:b8caa902d79e
- Child:
- 6:e35a1f72d90f
File content as of revision 5:2a28b4664b0a:
#include "mbed.h" #include "USBMouse.h" USBMouse mouse(ABS_MOUSE); AnalogIn potA(p20); AnalogIn potB(p19); BusIn button(p12,p15,p13,p16); DigitalIn fire(p14); int lastButtonState=0,buttonChanged=0,buttonState=0; float x,y; int main() { while (1) { #ifdef FLOATPOT x= 0x7fff * potA.read(); y= 0x7fff * potB.read(); #else x= ( potA.read_u16() & 0xfff0 ) >> 1; y= ( potB.read_u16() & 0xfff0 ) >> 1; #endif buttonState = button.read() & 0x7; buttonChanged = buttonState ^ lastButtonState; mouse.move(x, y); mouse.press(buttonState & buttonChanged); mouse.release(!buttonState & buttonChanged); wait(0.001); } }