controllare 2 servi con 2 potenziometri!

ho fatto in questo modo:

servo1: ho collegato il +5v e il gnd ai rispettivi piedini di arduino, e il cavo dati al pin 9
servo2: idem, ma il cavo dati al pin10

pot1: piedino centrale al pinA0, e i 2 laterali ai pin +5v e gnd di arduino
pot2: idem, ma il centrale a A1

Risultato: ne comando solo uno, l' altro nn si muove! :frowning:

Forse bisogna cambiare il codice

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.attach(10); // secondo servo al pin 10
}

con

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(10); // secondo servo al pin 10
}

Ciao
QP

si ti stavo scrivendo la stessa cosa...

ho provato a fare la modifica allo sketch, ma nn me lo permette e mi da errore!

Binary sketch size: 2120 bytes (of a 32256 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Sbagliavo: Funzionaa! ok, bidognava assegnare il 2 al secondo servo!

Ciao a Tutti, sono nuovo e molto poco esperto di Arduino e programmazione. Sto utilizzando Arduino Uno per comandare 3 servo tramite 3 potenziometri, per remotare il Pan, Tilt e Focus di una videocamera.
Ho trovato in rete questo progetto (comanda un servo con un potenziometro) che ho provato e funziona benissimo.

http://www.niklas-ruehl.de/wp-content/uploads/diy_rff_wiring_code.pdf

Quello che vorrei realizzare è di moltiplicare per 3 il tutto.
Ho cercato di scrivere lo sketch attingendo a quelli indicati nel post precedente:

#include <Servo.h>

Servo servo1; // create servo object to control a servo1
int potpin1 = 0; // analog pin used to connect the potentiometer 1
int val1; // variable to read the value from the analog pin (1024 steps from 0 to 1023)
Servo servo2; // create servo object to control a servo2
int potpin2 = 1; // analog pin used to connect the potentiometer 2
int val2; // variable to read the value from the analog pin (1024 steps from 0 to 1023)
Servo servo3; // create servo object to control a servo3
int potpin3 = 2; // analog pin used to connect the potentiometer 3
int val3; // variable to read the value from the analog pin (1024 steps from 0 to 1023)

void setup()
{
Serial.begin(9600); // start serial communication
servo1.attach(8); // attaches the servo on pin 8 to the servo1 object
servo2.attach(9); // attaches the servo on pin 9 to the servo2 object
servo3.attach(10); // attaches the servo on pin 10 to the servo3 object
}

void loop()
{
val1 = analogRead(potpin1);
int oneturn = val1 / 6; // 6-Turn-Servo uses only one turn (can also be more or less, depending on your lens and gear wheel diameter)
val2 = analogRead(potpin2);
val3 = analogRead(potpin3);

int servoposition = oneturn + 1001; // translates 1024 poti steps into val / 6 servo steps
Serial.println(servoposition); // for test purposes, you can see the poti values in the serial monitor

servo1.writeMicroseconds(servoposition); // servo gets position information
servo2.writeMicroseconds(servoposition); // servo gets position information
servo3.writeMicroseconds(servoposition); // servo gets position information

}

purtroppo quesllo che ho ottenuto è che ogni potenziometro comanda i 3 servo contemporaneamente.
Qualcuno mi può correggere?
Premetto che i servo da comandare non sono dei semplici servo che devono girare di 180° ma dei verricelli che possono compiere fino ad un massimo di 6 giri.
Grazie a tutti