Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void vaia(int x, int y, int speed, int step) {
- posx = servoX.read(); //Legge la posizione di servoX
- posy = servoY.read(); //Legge la posizione di servoY
- if (x > posx) { incx = step; } else if (x < posx) { incx = -step; } else { incx = 0 }
- if (y > posy) { incy = step; } else if (y < posy) { incy = -step; } else { incy = 0 }
- while ( ((incx == step) && (x > posx)) || ((incx == -step) && (x < posx)) ) {
- posx = servoX.read();
- servoX.write(posx + incx);
- delay(speed);
- }
- while ( ((incy == step) && (y > posy)) || ((incy == -step) && (y < posy)) ) {
- posy = servoY.read();
- servoY.write(posy + incy);
- delay(speed);
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement