Guest User

Untitled

a guest
Jun 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <Servo.h>
  2. const int x=A0,y=A1,z=A2;
  3. int b=0;
  4. int xPos,yPos;
  5. int t = 0;
  6. Servo myservo,m2,m3;
  7.  
  8. int pos = 0,pos2=0,pos3=0;
  9. void setup() {
  10. myservo.attach(8);
  11. m2.attach(9);
  12. m3.attach(10);
  13. Serial.begin(9600);
  14. pinMode(z, INPUT_PULLUP);
  15. }
  16.  
  17. void loop() {
  18. xPos = analogRead(x);
  19. xPos=map(xPos,0,1023,0,180);
  20. myservo.write(xPos);
  21.  
  22. yPos = analogRead(y);
  23. yPos=map(yPos,0,1023,0,180);
  24. m2.write(yPos);
  25.  
  26. b=digitalRead(z);
  27. if(b == 0){
  28. pos3 = 70;
  29. m3.write(pos3);
  30. }else{
  31. pos3 = 0;
  32. m3.write(pos3);
  33. }
  34. }
Add Comment
Please, Sign In to add comment