# Bras robot besoin aide

salut a tous .

voila je suis sur le projet bras robot mais j'ai un probleme sur sa vitesse d'initialisation qui va trop vite .
Comment puis-je regler cette vitesse de demarrage, pour qu'il puisse prendre la valeur des potards a la bonne vitesse ? j'ai changer une partie du code pour fixer la vitesse avant d'attacher les servo mais ne veut rien savoir help me please .....

``````#include <VarSpeedServo.h>

VarSpeedServo servo1,servo2,servo3,servo4;

const int servo1pin = 12; //Servos
const int servo2pin = 11;
const int servo3pin = 10;
const int servo4pin = 9 ;

const int button1 = 2; //Buttons
const int button2 = 3;

int button1Presses = 0; //Button values
boolean button2Pressed = false;

const int pot1 = A0; //Potentimeters
const int pot2 = A1;
const int pot3 = A2;
const int pot4 = A3;

int pot1Val; //Potentimeter values
int pot2Val;
int pot3Val;
int pot4Val;
int pot1Angle;
int pot2Angle;
int pot3Angle;
int pot4Angle;

int servo1PosSaves[] = {1,1,1,1,1}; //position saves
int servo2PosSaves[] = {1,1,1,1,1};
int servo3PosSaves[] = {1,1,1,1,1};
int servo4PosSaves[] = {1,1,1,1,1};

void setup() {

servo1.write(pot1Angle,10); // These will make the servos move to the mapped angles
servo2.write(pot2Angle,10);
servo3.write(pot3Angle,10);
servo4.write(pot4Angle,10);

servo1.attach(12,750,2130); // Set up everything and will run once; attach servos and define the pin modes
servo2.attach(11,750,2130);
servo3.attach(10);
servo4.attach(9);

pinMode(button1, INPUT);
pinMode(button2, INPUT);

Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:

pot1Val = analogRead(pot1); // This will read the values from the potentimeters and store it...
pot1Angle = map(pot1Val, 0, 1023, 0, 179); // ... and this will map the values from the potentiometers to values the servos can use and store it for later use
pot2Angle = map(pot2Val, 0, 1023, 0, 179);
pot3Angle = map(pot3Val, 0, 1023, 0, 179);
pot4Angle = map(pot3Val, 0, 1023, 0, 179);

servo1.write(pot1Angle,10); // These will make the servos move to the mapped angles
servo2.write(pot2Angle,10);
servo3.write(pot3Angle,10);
servo4.write(pot4Angle,10);

if(digitalRead(button1) == HIGH){ // This will check how many times button1 is pressed and save the positions to an array depending on how many times it is pressed; switch/case works like a if statement
button1Presses++;
switch(button1Presses){
case 1:
servo1PosSaves[0] = pot1Angle;
servo2PosSaves[0] = pot2Angle;
servo3PosSaves[0] = pot3Angle;
servo4PosSaves[0] = pot4Angle;

Serial.println("Pos 1 Saved");
break;
case 2:
servo1PosSaves[1] = pot1Angle;
servo2PosSaves[1] = pot2Angle;
servo3PosSaves[1] = pot3Angle;
servo4PosSaves[1] = pot4Angle;

Serial.println("Pos 2 Saved");
break;
case 3:
servo1PosSaves[2] = pot1Angle;
servo2PosSaves[2] = pot2Angle;
servo3PosSaves[2] = pot3Angle;
servo4PosSaves[2] = pot4Angle;

Serial.println("Pos 3 Saved");
break;
case 4:
servo1PosSaves[3] = pot1Angle;
servo2PosSaves[3] = pot2Angle;
servo3PosSaves[3] = pot3Angle;
servo4PosSaves[3] = pot4Angle;

Serial.println("Pos 4 Saved");
break;
case 5:
servo1PosSaves[4] = pot1Angle;
servo2PosSaves[4] = pot2Angle;
servo3PosSaves[4] = pot3Angle;
servo4PosSaves[4] = pot4Angle;

Serial.println("Pos 5 Saved");
break;
}
}

if(digitalRead(button2) == HIGH){ // Pretty self-explnatory here
button2Pressed = true;
}

if(button2Pressed){ // if the boolean button2Press is true, then the servos will run though all their saved positions
for(int i = 0; i < 5; i++){
servo1.write(servo1PosSaves[i],30);
servo2.write(servo2PosSaves[i],30);
servo3.write(servo3PosSaves[i],30);
servo4.write(servo4PosSaves[i],30);
Serial.println(" potentimeter Angles: ");
Serial.println(servo1PosSaves[i]);
Serial.println(servo2PosSaves[i]);
Serial.println(servo3PosSaves[i]);
Serial.println(servo4PosSaves[i]);

delay(1000);
}
}
delay(100);
}
``````

Comment puis-je régler cette vitesse de démarrage, pour qu'il puisse prendre la valeur des potards a la bonne vitesse

Bonjour,
il faut tout simplement interdire de toucher aux potentiomètres pendant l'arrêt du robot

par ailleurs il faut sans doute que tu relises les définitions de

servo1.attach(12,750,2130);
servo1.write(pot1Angle,10);
myServo.slowmove (newpos, speed);