#include <Servo.h>
Servo myservo0;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
int retardo = 10;
int potpin0 = 0;
int val0;
int potpin1 = 1;
int val1;
int potpin2 = 2;
int val2;
int potpin3 = 3;
int val3;
int potpin4 = 4;
int val4;
int potpin5 = 5;
int val5;
void setup() {
Serial.begin(9600);
myservo0.attach(2);
myservo1.attach(3);
myservo2.attach(4);
myservo3.attach(5);
myservo4.attach(6);
myservo5.attach(7);
pinMode(13,OUTPUT);
}
void loop() {
val0 = analogRead(potpin0);
val0 = map(val0, 0, 1023, 0, 180);
myservo0.write(val0);
delay(retardo);
val1 = analogRead(potpin1);
val1 = map(val1, 0, 1023, 65, 180);
myservo1.write(val1);
delay(retardo);
val2 = analogRead(potpin2);
val2 = map(val2, 0, 1023, 80, 180);
myservo2.write(val2);
delay(retardo);
val3 = analogRead(potpin3);
val3 = map(val3, 0, 1023, 90, 180);
myservo3.write(val3);
delay(retardo);
val4 = analogRead(potpin4);
val4 = map(val4, 0, 1023, 0, 180);
myservo4.write(val4);
delay(retardo);
val5 = analogRead(potpin5);
val5 = map(val5, 0, 1023, 0, 180);
myservo5.write(val5);
delay(retardo);
Serial.print(" val0 (mesa) : ");
Serial.print(val0);
Serial.print(" val1 (ombro) : ");
Serial.print(val1);
Serial.print(" val2 (cotovelo): ");
Serial.print(val2);
Serial.print(" val3 (punho): ");
Serial.print(val3);
Serial.print(" val4 (giro): ");
Serial.print(val4);
Serial.print(" val5 (garra): ");
Serial.println(val5);
}
Nenhum comentário:
Postar um comentário