si j'ai déclaré les boutons
en vrai mon code c'est ça
#include <AccelStepper.h>
#include <MultiStepper.h>
#include <LiquidCrystal.h>
#include <Servo.h>
AccelStepper collimation1(AccelStepper::DRIVER, 53, 52);
AccelStepper collimation2(AccelStepper::DRIVER, 10, 11);
AccelStepper collimation3(AccelStepper::DRIVER, 6, 7);
AccelStepper moteurAD(AccelStepper::DRIVER, 51, 50);
AccelStepper moteurDEC(AccelStepper::DRIVER, 12, 13);
AccelStepper focuser(AccelStepper::DRIVER, 8, 9);
LiquidCrystal lcd (45, 44, 46, 47, 48, 49);
int batinovPin = 22;
Servo Batinov;
const int bouton1 = 24;
const int bouton2 = 25;
const int bouton3 = 26;
const int bouton4 = 27;
const int bouton5 = 28;
const int bouton6 = 29;
const int bouton7 = 30;
const int bouton8 = 31;
const int bouton9 = 32;
const int bouton10 = 33;
const int bouton11 = 34;
const int bouton12 = 35;
const int bouton13 = 36;
const int bouton14 = 37;
const int bouton15 = 38;
const int bouton16 = 39;
const int bouton17 = 40;
const int bouton18 = 41;
const int bouton19 = 42;
const int bouton20 = 43;
const int ST4ADplus = 2;
const int ST4DECplus = 3;
const int ST4DECminus = 4;
const int ST4ADminus = 5;
void setup() {
pinMode (bouton1, INPUT_PULLUP);
pinMode (bouton2, INPUT_PULLUP);
pinMode (bouton3, INPUT_PULLUP);
pinMode (bouton4, INPUT_PULLUP);
pinMode (bouton5, INPUT_PULLUP);
pinMode (bouton6, INPUT_PULLUP);
pinMode (bouton7, INPUT_PULLUP);
pinMode (bouton8, INPUT_PULLUP);
pinMode (bouton9, INPUT_PULLUP);
pinMode (bouton10, INPUT_PULLUP);
pinMode (bouton11, INPUT_PULLUP);
pinMode (bouton12, INPUT_PULLUP);
pinMode (bouton13, INPUT_PULLUP);
pinMode (bouton14, INPUT_PULLUP);
pinMode (bouton15, INPUT_PULLUP);
pinMode (bouton16, INPUT_PULLUP);
pinMode (bouton17, INPUT_PULLUP);
pinMode (bouton18, INPUT_PULLUP);
pinMode (bouton19, INPUT_PULLUP);
pinMode (bouton20, INPUT_PULLUP);
pinMode (ST4ADplus, INPUT_PULLUP);
pinMode (ST4DECplus, INPUT_PULLUP);
pinMode (ST4DECminus, INPUT_PULLUP);
pinMode (ST4ADminus, INPUT_PULLUP);
collimation1.setMaxSpeed(1000);
collimation1.setSpeed(0);
collimation2.setMaxSpeed(1000);
collimation2.setSpeed(0);
collimation3.setMaxSpeed(1000);
collimation3.setSpeed(0);
moteurAD.setMaxSpeed(1000);
moteurAD.setSpeed(0);
moteurDEC.setMaxSpeed(1000);
moteurDEC.setSpeed(0);
focuser.setMaxSpeed(1000);
focuser.setSpeed(0);
lcd.begin(16, 2);
Batinov.attach(batinovPin);
Batinov.write(0);
}
void loop() {
if (digitalRead(bouton1) == LOW) {
collimation1.setSpeed(100);
}
else if (digitalRead(bouton2) == LOW) {
collimation1.setSpeed(-100);
}
else {
collimation1.setSpeed(0);
}
collimation1.runSpeed();
if (digitalRead(bouton3) == LOW) {
collimation2.setSpeed(100);
}
else if (digitalRead(bouton4) == LOW) {
collimation2.setSpeed(-100);
}
else {
collimation2.setSpeed(0);
}
collimation2.runSpeed();
if (digitalRead(bouton5) == LOW) {
collimation3.setSpeed(100);
}
else if (digitalRead(bouton6) == LOW) {
collimation3.setSpeed(-100);
}
else {
collimation3.setSpeed(0);
}
collimation3.runSpeed();
if (digitalRead(bouton7) == LOW) {
moteurAD.setSpeed(100);
}
else if (digitalRead(bouton8) == LOW) {
moteurAD.setSpeed(-100);
}
else {
moteurAD.setSpeed(0);
}
moteurAD.runSpeed();
if (digitalRead(bouton9) == LOW) {
moteurDEC.setSpeed(100);
}
else if (digitalRead(bouton10) == LOW) {
moteurDEC.setSpeed(-100);
}
else {
moteurDEC.setSpeed(0);
}
moteurDEC.runSpeed();
if (digitalRead(bouton11) == LOW) {
focuser.setSpeed(100);
}
else if (digitalRead(bouton12) == LOW) {
focuser.setSpeed(-100);
}
else {
focuser.setSpeed(0);
}
focuser.runSpeed();
if (digitalRead(bouton13) == LOW) {
Batinov.write(0);
}
else if (digitalRead(bouton14) == LOW) {
Batinov.write(200);
}
}
je suis sur une arduino mega 2560
avec else if ça marche
merci cdt
cdt