1
2
3#include <Servo.h>
4Servo arm ;
5Servo turn ;
6Servo claw ;
7Servo claw2 ;
8
9 int potpin = 0;
10int val;
11int potpin2 = 1;
12int val2;
13int potpin3 = 2;
14int val3;
15
16
17
18void setup() {
19
20turn.attach(13) ;
21 arm.attach(12) ;
22 claw.attach(11) ;
23 claw2.attach(10) ;
24
25
26
27
28}
29void loop() {
30
31val = analogRead(potpin);
32 val = map(val, 0, 1023, 0, 180);
33 turn.write(val);
34 delay(15);
35
36 val2 = analogRead(potpin2);
37 val2 = map(val2, 0, 1023, 0, 180);
38 arm.write(val2);
39 delay(15);
40
41 val3 = analogRead(potpin3);
42 val3 = map(val3, 0, 1023, 0, 180);
43
44 delay(15);
45 if(val3 < 90){
46 claw.write(180);
47 claw2.write(90);
48 }
49 else if(val3 > 90){
50 claw.write(90);
51 claw2.write(180);
52 }
53 }
54