![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Clicks mouse
Diff: main.cpp
- Revision:
- 0:7e0200844583
diff -r 000000000000 -r 7e0200844583 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 17 13:38:13 2020 +0000 @@ -0,0 +1,62 @@ +// USB Device demo - control mouse pointer with buttons + +#include "mbed.h" +#include "USBMouse.h" + +// USB Mouse object +USBMouse mouse; + +// Define buttons +DigitalIn button_click(p5); +DigitalIn button_scrollup(p6); +DigitalIn button_scrolldown(p7); + + +DigitalOut myled(LED1); + +Timer timer1; + +int main() { + int x; + int y; + int z; + + + while (1) { + y = 1; + z = 1; + x = -1; + + + if ( button_scrolldown ) { + x = 0; + } + + if ( button_click ) { + z = 0; + } + + if ( button_scrollup ) { + y = 0; + } + + // Click mouse + + timer1.start(); + if (timer1.read_ms()>=100) { + mouse.click(z); //cliicks + timer1.stop(); + timer1.reset(); + } + + mouse.scroll(y); //scrolls up + mouse.scroll(x); //scrolls down + + mouse.release(1); + + + + // Wait for next cycle + + } +} \ No newline at end of file