Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- const int x=A0,y=A1,z=A2;
- int b=0;
- int xPos,yPos;
- int t = 0;
- Servo myservo,m2,m3;
- int pos = 0,pos2=0,pos3=0;
- void setup() {
- myservo.attach(8);
- m2.attach(9);
- m3.attach(10);
- Serial.begin(9600);
- pinMode(z, INPUT_PULLUP);
- }
- void loop() {
- xPos = analogRead(x);
- xPos=map(xPos,0,1023,0,180);
- myservo.write(xPos);
- yPos = analogRead(y);
- yPos=map(yPos,0,1023,0,180);
- m2.write(yPos);
- b=digitalRead(z);
- if(b == 0){
- pos3 = 70;
- m3.write(pos3);
- }else{
- pos3 = 0;
- m3.write(pos3);
- }
- }
Add Comment
Please, Sign In to add comment