Advertisement
Guest User

Untitled

a guest
Jul 21st, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include "mbed.h"
  2. #include "USBMouse.h"
  3.  
  4. //create mouse object
  5. USBMouse mouse;
  6.  
  7. int main()
  8. {
  9.     int16_t x = 0;
  10.     int16_t y = 0;
  11.     double radius = 20;
  12.     int32_t angle = 0;
  13.  
  14.     while (1) {
  15.         //will cause mouse to move in a circle
  16.         x = cos((double)angle * 3.14 / 180.0) * (int32_t)radius;
  17.         y = sin((double)angle * 3.14 / 180.0) * (int32_t)radius;
  18.  
  19.         //will move mouse x, y away from its previous position on the screen
  20.         mouse.move(x, y);
  21.         angle += 3;
  22.         ThisThread::sleep_for(10);
  23.  
  24.         radius *= 0.9995;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement