Voici mon code si ça peut aider :
#include <Servo.h>
//initialisation des capteurs
int Capteur1_1Pin = 21;
int Capteur1_2Pin = 22;
int Capteur1_3Pin = 23;
int Capteur1_4Pin = 24;
int Capteur2_1Pin = 25;
int Capteur2_2Pin = 26;
int Capteur2_3Pin = 27;
//initialisation des LED de guidage
int LedGuide1_1Pin = 31;
int LedGuide1_2Pin = 32;
int LedGuide1_3Pin = 33;
int LedGuide1_4Pin = 34;
int LedGuide2_1Pin = 35;
int LedGuide2_2Pin = 36;
int LedGuide2_3Pin = 37;
//initialisation des LED de couloir
int LedCouloir1Pin = 40;
int LedCouloir2Pin = 41;
//initialisation des segments
int Segment1Pin = 44;
int Segment2Pin = 45;
int Segment3Pin = 46;
int Segment4Pin = 47;
int Segment5Pin = 48;
int Segment6Pin = 49;
int Segment7Pin = 50;
int Segment8Pin = 51;
//initialisation des servomoteurs
Servo servo_entree;
Servo servo_sortie;
//initialisation des boutons
int BoutonEntreePin = 6;
int BoutonSortiePin = 7;
//initialisation des variables
int place = 7;
int placex = 0;
void setup() {
Serial.begin(9600); //init. de la connexion avec le moniteur série
Serial.println("Programme lance");
// initialisation des capteurs
Serial.println("");
Serial.print("Initialisation des capteurs : ");
pinMode(Capteur1_1Pin, INPUT); //init. capteur place 1
pinMode(Capteur1_2Pin, INPUT); //init. capteur place 2
pinMode(Capteur1_3Pin, INPUT); //init. capteur place 3
pinMode(Capteur1_4Pin, INPUT); //init. capteur place 4
pinMode(Capteur2_1Pin, INPUT); //init. capteur place 5
pinMode(Capteur2_2Pin, INPUT); //init. capteur place 6
pinMode(Capteur2_3Pin, INPUT); //init. capteur place 7
Serial.print("terminee");
//initialisation des LED de guidage
Serial.println("");
Serial.print("Initialisation des LED de guidage : ");
pinMode(LedGuide1_1Pin, OUTPUT); //init. LED place 1
pinMode(LedGuide1_2Pin, OUTPUT); //init. LED place 2
pinMode(LedGuide1_3Pin, OUTPUT); //init. LED place 3
pinMode(LedGuide1_4Pin, OUTPUT); //init. LED place 4
pinMode(LedGuide2_1Pin, OUTPUT); //init. LED place 5
pinMode(LedGuide2_2Pin, OUTPUT); //init. LED place 6
pinMode(LedGuide2_3Pin, OUTPUT); //init. LED place 7
Serial.print("terminee");
//initialisation des LED de couloir
Serial.println("");
Serial.print("Initialisation des LED des couloirs : ");
pinMode(LedCouloir1Pin, OUTPUT); //init. LED couloir 1 (p. 1,2,3 & 4)
pinMode(LedCouloir2Pin, OUTPUT); //init. LED couloir 2 (p. 5,6 & 7)
Serial.print("terminee");
//initialisation 7 segments 1
Serial.println("");
Serial.print("Initialisation du 7 segments : ");
pinMode(Segment1Pin, OUTPUT); //init. segment
pinMode(Segment2Pin, OUTPUT); //init. segment
pinMode(Segment3Pin, OUTPUT); //init. segment
pinMode(Segment4Pin, OUTPUT); //init. segment
pinMode(Segment5Pin, OUTPUT); //init. segment
pinMode(Segment6Pin, OUTPUT); //init. segment
pinMode(Segment7Pin, OUTPUT); //init. segment
pinMode(Segment8Pin, OUTPUT); //init. segment
Serial.print("terminee");
//initialisation des servomoteurs
Serial.println("");
Serial.print("Initialisation des servomoteurs : ");
servo_entree.attach(2); //init. servomoteur entree
servo_sortie.attach(3); //init. servomoteur sortie
Serial.print("terminee");
//initialisation bouton
Serial.println("");
Serial.print("Initialisation des boutons : ");
pinMode(BoutonEntreePin, INPUT); //init. bouton entrée
pinMode(BoutonSortiePin, INPUT); //init. bouton sortie
Serial.print("terminee");
Serial.println("");
Serial.println("");
Serial.println("Initialisation terminee");
}
void loop() {
// put your main code here, to run repeatedly:
if(BoutonEntree==1)
{
servo_entree.attach(90); //met le servomoteur d'entrée à 90°
place=place-1;
}
if(BoutonSortie==1)
{
servo_sortie.attach(90); //met le servomoteur de sortie à 90°
place=place+1;
}
if(place != placex) // Si place n'est pas égal à place tour-1
{
if (place == 0) //Si place=0, affiche 0
{
digital.Write(Segment1Pin,HIGH);
digital.Write(Segment2Pin,HIGH);
digital.Write(Segment3Pin,HIGH);
digital.Write(Segment4Pin,LOW);
digital.Write(Segment5Pin,HIGH);
digital.Write(Segment6Pin,HIGH);
digital.Write(Segment7Pin,HIGH);
digital.Write(Segment8Pin,LOW);
}
if (place == 1) //Si place=1, affiche 1
{
digital.Write(Segment1Pin,LOW);
digital.Write(Segment2Pin,LOW);
digital.Write(Segment3Pin,HIGH);
digital.Write(Segment4Pin,LOW);
digital.Write(Segment5Pin,LOW);
digital.Write(Segment6Pin,HIGH);
digital.Write(Segment7Pin,LOW);
digital.Write(Segment8Pin,LOW);
}
if (place == 2) //Si place=2, affiche 2
{
digital.Write(Segment1Pin,LOW);
digital.Write(Segment2Pin,HIGH);
digital.Write(Segment3Pin,HIGH);
digital.Write(Segment4Pin,HIGH);
digital.Write(Segment5Pin,HIGH);
digital.Write(Segment6Pin,LOW);
digital.Write(Segment7Pin,HIGH);
digital.Write(Segment8Pin,LOW);
}
if (place == 3) //Si place=3, affiche 3
{
digital.Write(Segment1Pin,LOW);
digital.Write(Segment2Pin,HIGH);
digital.Write(Segment3Pin,HIGH);
digital.Write(Segment4Pin,HIGH);
digital.Write(Segment5Pin,LOW);
digital.Write(Segment6Pin,HIGH);
digital.Write(Segment7Pin,HIGH);
digital.Write(Segment8Pin,LOW);
}
if (place == 4) //Si place=4, affiche 4
{
digital.Write(Segment1Pin,HIGH);
digital.Write(Segment2Pin,LOW);
digital.Write(Segment3Pin,HIGH);
digital.Write(Segment4Pin,HIGH);
digital.Write(Segment5Pin,LOW);
digital.Write(Segment6Pin,HIGH);
digital.Write(Segment7Pin,LOW);
digital.Write(Segment8Pin,LOW);
}
if (place == 5) //Si place=5, affiche 5
{
digital.Write(Segment1Pin,HIGH);
digital.Write(Segment2Pin,HIGH);
digital.Write(Segment3Pin,LOW);
digital.Write(Segment4Pin,HIGH);
digital.Write(Segment5Pin,LOW);
digital.Write(Segment6Pin,HIGH);
digital.Write(Segment7Pin,HIGH);
digital.Write(Segment8Pin,LOW);
}
if (place == 6) //Si place=6, affiche 6
{
digital.Write(Segment1Pin,HIGH);
digital.Write(Segment2Pin,HIGH);
digital.Write(Segment3Pin,LOW);
digital.Write(Segment4Pin,HIGH);
digital.Write(Segment5Pin,HIGH);
digital.Write(Segment6Pin,HIGH);
digital.Write(Segment7Pin,HIGH);
digital.Write(Segment8Pin,LOW);
}
if (place == 7) //Si place=7, affiche 7
{
digital.Write(Segment1Pin,LOW);
digital.Write(Segment2Pin,HIGH);
digital.Write(Segment3Pin,HIGH);
digital.Write(Segment4Pin,LOW);
digital.Write(Segment5Pin,LOW);
digital.Write(Segment6Pin,HIGH);
digital.Write(Segment7Pin,LOW);
digital.Write(Segment8Pin,LOW);
}
if (place <= 0 || place >= 7) //Si place= + que 7 ou - que 0, affiche E(rreur)
{
digital.Write(Segment1Pin,HIGH);
digital.Write(Segment2Pin,HIGH);
digital.Write(Segment3Pin,LOW);
digital.Write(Segment4Pin,HIGH);
digital.Write(Segment5Pin,HIGH);
digital.Write(Segment6Pin,LOW);
digital.Write(Segment7Pin,HIGH);
digital.Write(Segment8Pin,LOW);
}
}
}