Bonjour,
j'ai branché deux servo sur deux sorties analogique différentes, et qu'ils sont piloté par deux potentiomètres différents.
Hors quand 1 seul est connecté ça marche, quand y'en a deux ça bug !
les servos font un aller retour à mis chemin du potentiomètre chose qu'ils ne font pas en temps normal...
voici le code !
merci d'avance
#include <Servo.h>
Servo myservo0; // create servo object to control a servo
Servo myservo1;
int potpin0 = 0; // analog pin used to connect the potentiometer
int potpin1 = 1; // analog pin used to connect the potentiometer
int val1; // variable to read the value from the analog pin
int val2; // variable to read the value from the analog pin
void setup()
{
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo0.attach(11); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val1 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val1 = map(val1, 0, 179, 0, 1023); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val1); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
val2 = analogRead(potpin0); // reads the value of the potentiometer (value between 0 and 1023)
val2 = map(val2, 0, 179, 0, 1023); // scale it to use it with the servo (value between 0 and 180)
myservo0.write(val2); // sets the servo position according to the scaled value
delay(15);
}