Advertisement
tpaper

Termidorians IIbis

Dec 30th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void vaia(int x, int y, int speed, int step) {
  2.     posx = servoX.read();   //Legge la posizione di servoX
  3.     posy = servoY.read();   //Legge la posizione di servoY
  4.     if (x > posx) { incx = step; } else if (x < posx) { incx = -step; } else { incx = 0 }
  5.     if (y > posy) { incy = step; } else if (y < posy) { incy = -step; } else { incy = 0 }
  6.     while ( ((incx == step) && (x > posx)) || ((incx == -step) && (x < posx)) ) {
  7.         posx = servoX.read();
  8.         servoX.write(posx + incx);
  9.         delay(speed);
  10.     }
  11.     while ( ((incy == step) && (y > posy)) || ((incy == -step) && (y < posy)) ) {
  12.         posy = servoY.read();
  13.         servoY.write(posy + incy);
  14.         delay(speed);
  15.     }
  16.     return;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement