Question machine à états

Bonjour,
je veut utiliser un bouton pour déclencher 3 programme différent, les 3 programme fonctionne séparément.
voici mon code:

#include <Arduino.h>
#define ENTREE_ANALOGIQUE 1
#include <OneButton.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#include <Fonts/FreeMono9pt7b.h>                    // Normal (en 9, 12, 18, et 24 pts)
#define nombreDePixelsEnLargeur 128         // Taille de l'écran OLED, en pixel, au niveau de sa largeur
#define nombreDePixelsEnHauteur 64          // Taille de l'écran OLED, en pixel, au niveau de sa hauteur
#define brocheResetOLED         -1          // Reset de l'OLED partagé avec l'Arduino (d'où la valeur à -1, et non un numéro de pin)
#define adresseI2CecranOLED     0x3C        // Adresse de "mon" écran OLED sur le bus i2c (généralement égal à 0x3C ou 0x3D)
#define IN1 10
#define IN2 5
Adafruit_SSD1306 ecranOLED(nombreDePixelsEnLargeur, nombreDePixelsEnHauteur, &Wire, brocheResetOLED);   // Le "Wire" indique qu'on travaille en I2C
const byte buttonPin = 13;

OneButton button(buttonPin, true);

volatile int bpMAV = 0;  //ON OFF
volatile int bpMAR = 0; //ON OFF
volatile int bpFINCOURSE = 0; //fin de course  du système
volatile int intPORTE = 0; // INTERRUPTEUR port
volatile int intCONTACTCLEF = 0; // INTERRUPTEUR clé
volatile int intAUTO = 0; // INTERRUPTEUR manuel/Auto

const int pourcent80 = 204;
const int pourcent20 = 50;
const int pourcent50 = 127;


int crono3 = 1300;
int cronall2 = 1000;

const char underscore[] = "__________";
const char egale[] = "=";
unsigned long chrono_marche_avant;
int marche_avant_active = 0;
unsigned long delai_marche_avant;
unsigned long chrono_marche_arriere;
int marche_arriere_active = 0;
unsigned long delai_marche_arriere;
unsigned long delai_marche_arriere2;

int obstacle_marche_avant = 0;
int obstacle_marche_arriere = 0;
unsigned long chrono_porte_ouverte ;
int porte_ouverte_active = 0;
unsigned long delai_porte_ouverte;
int marche_arriere_obstacle_active = 0;
unsigned long delai_marche_arriere_obstacle;
unsigned long chrono_marche_arriere_obstacle;
int marche_avant_obstacle_active = 0;
unsigned long delai_marche_avant_obstacle;
unsigned long chrono_marche_avant_obstacle;

float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

int flag = 0;
int flag1 = 0;
unsigned long chrono;
const unsigned long TimeOut = 15000ul;


const unsigned char myBitmap [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0c, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0x0f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0x27, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe2, 0x7e, 0x4f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe4, 0x7c, 0xcf, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc4, 0xe1, 0x8f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x88, 0x03, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf2, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xfc, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xc0, 0x7f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xc0, 0x02, 0x3f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfc, 0x3f, 0xff, 0xfd, 0x0f, 0xe0, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfe, 0x1f, 0xff, 0xfc, 0x3f, 0xf8, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xff, 0x0f, 0xff, 0xf8, 0x7f, 0xf8, 0x7f, 0xfb, 0x1f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x8f, 0xff, 0x07, 0xff, 0xf1, 0xff, 0xf8, 0x7f, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xc3, 0xfe, 0x83, 0xff, 0xe3, 0xff, 0xf0, 0xff, 0xfe, 0x07, 0x03, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xe0, 0xff, 0xe1, 0xff, 0xc7, 0xff, 0xf0, 0xff, 0xfc, 0x3f, 0xf1, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0xff, 0x80, 0xff, 0xc7, 0xff, 0xe1, 0xff, 0xfc, 0x7f, 0xd9, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x7f, 0x00, 0x3f, 0x8f, 0xff, 0xc1, 0xff, 0xf8, 0x7f, 0xf8, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x3f, 0x00, 0x00, 0x1f, 0xff, 0xc3, 0xff, 0xf8, 0xff, 0xf0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x00, 0x01, 0x00, 0x1f, 0xff, 0x87, 0xff, 0xf0, 0xff, 0xf1, 0x8f, 0xff, 0xff,
  0xff, 0xff, 0xfc, 0x00, 0x01, 0x84, 0x3f, 0xff, 0x87, 0xff, 0xf1, 0xff, 0xf1, 0xc7, 0xff, 0xff,
  0xff, 0xff, 0xfe, 0x00, 0x01, 0x80, 0x7f, 0xff, 0x0f, 0xff, 0xe1, 0xff, 0xe3, 0xe7, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x1f, 0xff, 0xe3, 0xff, 0xc3, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x80, 0xff, 0x00, 0xff, 0xfe, 0x1f, 0xff, 0xc3, 0xff, 0x87, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xc3, 0xff, 0xc0, 0xff, 0xfe, 0x3f, 0xff, 0xc7, 0xff, 0xc7, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xe1, 0xff, 0xc1, 0xff, 0xfe, 0x7f, 0xff, 0x87, 0xff, 0x8f, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf1, 0xff, 0x81, 0xff, 0xfc, 0xff, 0xff, 0x8f, 0xff, 0x8f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf8, 0x7e, 0x03, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0x0f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xfc, 0x18, 0x03, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0x1f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x3f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xfd, 0xff, 0xf8, 0x00, 0xf0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x80, 0x00, 0x7f, 0xf9, 0xff, 0xc0, 0x01, 0xe0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0x80, 0x00, 0x0f, 0x80, 0x3f, 0x00, 0x7f, 0xc1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x07, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x3f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x05, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x10, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// '106870349-vecteur-d-icône-de-porte-isolé-sur-fond-blanc-pour-la-conception-de-votre-application-web-et-mobile-', 128x64px
const unsigned char myBitmap1 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// 'istockphoto-1140967663-612x612', 128x64px
const unsigned char myBitmap2 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};



void ecran (const char *valeur1, const char *ouvert_ferme, const char *valeur2, int etat2 , const char *valeur3, int etat3 , const char *valeur4, int etat4 )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur1);
  ecranOLED.print(egale);
  ecranOLED.println(ouvert_ferme);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur2);
  ecranOLED.print(egale);
  ecranOLED.println(etat2);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur3);
  ecranOLED.print(egale);
  ecranOLED.println(etat3);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur4);
  ecranOLED.print(egale);
  ecranOLED.println(etat4);
  ecranOLED.println(underscore);
  ecranOLED.display();


}

void mesure (const char *valeur, float tension )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur);
  ecranOLED.print(egale);
  ecranOLED.print(tension);
  ecranOLED.println(F(" V "));
  ecranOLED.display();
}

void warning (const char *warm  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(2);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.println(warm);
  ecranOLED.println(underscore);
  ecranOLED.display();


}
void image (const unsigned char *img  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap, 128, 64, 1);
  ecranOLED.display();


}
void image1 (const unsigned char *img1  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap1, 128, 64, 1);
  ecranOLED.display();


}
void image2 (const unsigned char *img2  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap2, 128, 64, 1);
  ecranOLED.display();


}
int marcheavant1 ()
{
  analogWrite(IN1, pourcent80);
  digitalWrite(IN2, LOW);

}
int marcheavant2 ()
{
  analogWrite(IN1, pourcent20);
  digitalWrite(IN2, LOW);

}
int marchearriere1 ()
{
  digitalWrite(IN1, LOW);
  analogWrite(IN2, pourcent80 );

}
int marchearriere2 ()
{
  digitalWrite(IN1, LOW);
  analogWrite(IN2, pourcent20 );

}
int Stop ()
{
  digitalWrite(IN1, LOW);

  digitalWrite(IN2, LOW );

}
void simpleclick()
{
 if (intAUTO == 0)
  {
    warning("Mode Auto");
  }
  if (intAUTO == 0 && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 )
      {

        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 0 && intPORTE == 1 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0)
      {

        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 0 && intCONTACTCLEF == 0 && intPORTE == 0)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);

        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 0  && intCONTACTCLEF == 0 && intPORTE == 1)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 1)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_arriere_active == 0 )
    {

      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_avant_active == 0 )
    {

      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 )
    {

      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {



    if (marche_avant_active == 0 )
    {
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 0 && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

    image(myBitmap1);



  }
  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_arriere_active == 0 )
    {

      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_avant_active == 0)
    {

      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }
  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output




  if (marche_avant_active == 1   )

  {
    marcheavant1();
    
  }

  if ( marche_avant_active == 1  && SensorRead < 2.00  )
    {
   
    Stop();
    marche_avant_active = 0;
    
    }

  if (marche_arriere_active == 1)

  {
    marche_avant_active = 0;


    marchearriere1();

  }

  if ( marche_arriere_active == 1 && bpFINCOURSE == 1)
  {

    Stop();
    marche_arriere_active = 0;

  }
  chrono = millis();
}

void doubleclick()
{
  if (intAUTO == 0)
  {
    warning("Mode Auto"); 
  }
  if (intAUTO == 0 && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 )
      {
        chrono_marche_avant = millis();
        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 0 && intPORTE == 1 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0 )
      {
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 0 && intCONTACTCLEF == 0 && intPORTE == 0)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 0  && intCONTACTCLEF == 0 && intPORTE == 1)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 1)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {



    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 0 && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

    image(myBitmap1);



  }
  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }


  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

  //Serial.print (F("SensorRead="));
  //Serial.println (SensorRead);


  //mesure("tension", SensorRead);




  if (marche_avant_active == 1 )
  {
    delai_marche_avant = millis() - chrono_marche_avant;

  }
  if (marche_avant_active == 1  && delai_marche_avant < 700 )

  {

    marche_arriere_active = 0;
    marcheavant1();

  }
  if ( marche_avant_active == 1  && delai_marche_avant <= 2500 && delai_marche_avant >= 700)
  {
    marche_arriere_active = 0;
    marcheavant2();

  }
  if ( marche_avant_active == 1  && delai_marche_avant > 2500 )
  {
    Stop();
    marche_avant_active = 0;

  }
  
  if (marche_arriere_active == 1  )
  {

    delai_marche_arriere = millis() - chrono_marche_arriere;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 900 )

  {
    marche_avant_active = 0;


    marchearriere1();

  }
  if ( marche_arriere_active == 1 && delai_marche_arriere >= 900)
  {
    marche_avant_active = 0;

    marchearriere2();

  }
  if ( marche_arriere_active == 1 && bpFINCOURSE == 1)
  {


    Stop();
    marche_arriere_active = 0;

  }
  chrono = millis();
}
void longclick()
{
  if (intAUTO == 0)
  {
    warning("Mode Auto"); 
  }
  if (intAUTO == 0 && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
      {
        chrono_marche_avant = millis();
        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 0 && intPORTE == 1 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 0 && intCONTACTCLEF == 0 && intPORTE == 0)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 0  && intCONTACTCLEF == 0 && intPORTE == 1)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 1)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1)
  {

    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {



    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 0 && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

    image(myBitmap1);



  }
  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }


  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

  //Serial.print (F("SensorRead="));
  //Serial.println (SensorRead);


  //mesure("tension", SensorRead);



  /* if (intCONTACTCLEF == 0 && bpFINCOURSE == 0)
    {
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("Retracter la marche avant de démarrer");

    }*/

  if (marche_avant_active == 1 )
  {
    delai_marche_avant = millis() - chrono_marche_avant;

  }
  if (marche_avant_active == 1  && delai_marche_avant < 1000 )

  {

    marche_arriere_active = 0;
    marcheavant1();

  }
  if ( marche_avant_active == 1  && delai_marche_avant <= 2200 && delai_marche_avant >= 1000)
  {
    marche_arriere_active = 0;
    marcheavant2();

  }
  if ( marche_avant_active == 1  && delai_marche_avant > 2200 )
  {
    Stop();
    marche_avant_active = 0;

  }

  if (marche_avant_active == 1  && delai_marche_avant < 2200 && SensorRead < 2.10)
  {
    chrono_marche_avant_obstacle = millis();
    marche_avant_active = 0;
    marche_avant_obstacle_active = 1;
  }

  if (marche_avant_obstacle_active == 1 )
  {
    delai_marche_avant_obstacle = millis() - chrono_marche_avant_obstacle;

    marchearriere1();

  }
  if ( marche_avant_obstacle_active == 1  && bpFINCOURSE == 1 )
  {

    Stop();
    marche_avant_obstacle_active = 0;
  }


  if (marche_arriere_active == 1  )
  {

    delai_marche_arriere = millis() - chrono_marche_arriere;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 1300 )

  {
    marche_avant_active = 0;


    marchearriere1();

  }
  if ( marche_arriere_active == 1 && delai_marche_arriere >= 1300)
  {
    marche_avant_active = 0;

    marchearriere2();

  }
  if ( marche_arriere_active == 1 && bpFINCOURSE == 1)
  {


    Stop();
    marche_arriere_active = 0;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 1800 && SensorRead > 3.00)
  {
    marche_arriere_active = 0;
    chrono_marche_arriere_obstacle = millis();
    marche_arriere_obstacle_active = 1;

  }

  if (marche_arriere_obstacle_active == 1)
  {
    delai_marche_arriere_obstacle = millis() - chrono_marche_arriere_obstacle;
    marcheavant1();

    delai_marche_arriere2 = delai_marche_arriere * 2;
  }
  if (marche_arriere_obstacle_active == 1 && delai_marche_arriere_obstacle >= (delai_marche_arriere2))
  {
    Stop();
    marche_arriere_obstacle_active = 0;
  }
  chrono = millis();
}


void setup()
{
  Serial.begin(9600);

  // Initialise le Timer 2 pour déclencher les interruptions à intervalle régulier
  TCCR2A = 0; //default
  TCCR2B = 0b00000110; // clk/256 est incrémenté toutes les 16uS
  TIMSK2 = 0b00000001; // TOIE2
  sei();               // autorise les interruptions


  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(3, INPUT_PULLUP); // INTERRUPTEUR intPORTE
  pinMode(9, INPUT_PULLUP); // INTERRUPTEUR intCONTACTCLEF
  pinMode(8, INPUT_PULLUP); // INTERRUPTEUR intAUTO
  pinMode(6, INPUT_PULLUP); //  pin marche avant
  pinMode(12, INPUT_PULLUP); // pin marche arrière
  pinMode(7, INPUT_PULLUP); // pin FIN COURSE

  button.attachClick(simpleclick);
  button.attachDoubleClick(doubleclick);
  button.attachLongPressStart (longclick);
}

void loop()
{

  button.tick();

}

// routine d'interruption du timer
ISR (TIMER2_OVF_vect)
{
  // 256-6 --> 250X16uS = 4mS
  // Recharge le timer pour que la prochaine interruption se déclenche dans 4mS
  TCNT2 = 6;
  //================================//
  //je vais lire  toutes les entrées//
  //================================//
  bpMAV = digitalRead (6);// le bp av
  bpMAR = digitalRead (12);// le bp arr
  intPORTE = digitalRead (3);// le bp intPORTE
  intCONTACTCLEF = digitalRead (9);// le bp intCONTACTCLEF
  intAUTO = digitalRead (8);// le bp intAUTO
  bpFINCOURSE = digitalRead (7);// le bpFINCOURSE
  //================================//
  //================================//
  //================================//

}

merci d'avance.

Ces instructions sont en dehors de toute fonction

button.attachClick(simpleclick);
button.attachDoubleClick(doubleclick);
button.attachLongPressStart (longclick);

Elles dedraient être dans le setup()

Ne postez pas dans le tuto pour un besoin particulier, ouvrez une question.
J’ai déplacé la conversation

bonjour,
désolé, c'est juste parce que c'était sur le même truc que vous avez fait avec les led .

ah oui c'est vrai j'ai pas remarquer, merci.
j'ai plus l'erreur mais mon programme ne marche pas comme je le veut.
quand je click sur le bouton il me met juste marche avant !!!

#include <Arduino.h>
#define ENTREE_ANALOGIQUE 1
#include <OneButton.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#include <Fonts/FreeMono9pt7b.h>                    // Normal (en 9, 12, 18, et 24 pts)
#define nombreDePixelsEnLargeur 128         // Taille de l'écran OLED, en pixel, au niveau de sa largeur
#define nombreDePixelsEnHauteur 64          // Taille de l'écran OLED, en pixel, au niveau de sa hauteur
#define brocheResetOLED         -1          // Reset de l'OLED partagé avec l'Arduino (d'où la valeur à -1, et non un numéro de pin)
#define adresseI2CecranOLED     0x3C        // Adresse de "mon" écran OLED sur le bus i2c (généralement égal à 0x3C ou 0x3D)
#define IN1 10
#define IN2 5
Adafruit_SSD1306 ecranOLED(nombreDePixelsEnLargeur, nombreDePixelsEnHauteur, &Wire, brocheResetOLED);   // Le "Wire" indique qu'on travaille en I2C
const byte buttonPin = 13;

OneButton button(buttonPin, true);


volatile int bpMAV = 0;  //ON OFF
volatile int bpMAR = 0; //ON OFF
volatile int bpFINCOURSE = 0; //fin de course  du système
volatile int intPORTE = 0; // INTERRUPTEUR port
volatile int intCONTACTCLEF = 0; // INTERRUPTEUR clé
volatile int intAUTO = 0; // INTERRUPTEUR manuel/Auto

const int pourcent80 = 204;
const int pourcent20 = 50;
const int pourcent50 = 127;


int crono3 = 1300;
int cronall2 = 1000;

const char underscore[] = "__________";
const char egale[] = "=";
unsigned long chrono_marche_avant;
int marche_avant_active = 0;
unsigned long delai_marche_avant;
unsigned long chrono_marche_arriere;
int marche_arriere_active = 0;
unsigned long delai_marche_arriere;
unsigned long delai_marche_arriere2;

int obstacle_marche_avant = 0;
int obstacle_marche_arriere = 0;
unsigned long chrono_porte_ouverte ;
int porte_ouverte_active = 0;
unsigned long delai_porte_ouverte;
int marche_arriere_obstacle_active = 0;
unsigned long delai_marche_arriere_obstacle;
unsigned long chrono_marche_arriere_obstacle;
int marche_avant_obstacle_active = 0;
unsigned long delai_marche_avant_obstacle;
unsigned long chrono_marche_avant_obstacle;

float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

int flag = 0;
int flag1 = 0;
unsigned long chrono;
const unsigned long TimeOut = 15000ul;





 void ecran (const char *valeur1, const char *ouvert_ferme, const char *valeur2, int etat2 , const char *valeur3, int etat3 , const char *valeur4, int etat4 )
  {
    ecranOLED.clearDisplay();
    ecranOLED.setTextSize(1);
    ecranOLED.setCursor(0, 0);
    ecranOLED.setTextColor(SSD1306_WHITE);
    ecranOLED.println(underscore);
    ecranOLED.print(valeur1);
    ecranOLED.print(egale);
    ecranOLED.println(ouvert_ferme);
    ecranOLED.println(underscore);
    ecranOLED.print(valeur2);
    ecranOLED.print(egale);
    ecranOLED.println(etat2);
    ecranOLED.println(underscore);
    ecranOLED.print(valeur3);
    ecranOLED.print(egale);
    ecranOLED.println(etat3);
    ecranOLED.println(underscore);
    ecranOLED.print(valeur4);
    ecranOLED.print(egale);
    ecranOLED.println(etat4);
    ecranOLED.println(underscore);
    ecranOLED.display();


  }

  

  void warning (const char *warm  )
  {
    ecranOLED.clearDisplay();
    ecranOLED.setTextSize(2);
    ecranOLED.setCursor(0, 0);
    ecranOLED.setTextColor(SSD1306_WHITE);
    ecranOLED.println(underscore);
    ecranOLED.println(warm);
    ecranOLED.println(underscore);
    ecranOLED.display();


  }
 
 
   int marcheavant1 ()
  {
    analogWrite(IN1, pourcent80);
    digitalWrite(IN2, LOW);

  }
  int marcheavant2 ()
  {
    analogWrite(IN1, pourcent20);
    digitalWrite(IN2, LOW);

  }
  int marchearriere1 ()
  {
    digitalWrite(IN1, LOW);
    analogWrite(IN2, pourcent80 );

  }
  int marchearriere2 ()
  {
    digitalWrite(IN1, LOW);
    analogWrite(IN2, pourcent20 );

  }
  int Stop ()
  {
    digitalWrite(IN1, LOW);

    digitalWrite(IN2, LOW );

  }
void simpleclick()
{
  if (intAUTO == 1)
  {
    warning("Mode Auto");
  }
  if (intAUTO == 1 && intPORTE == 1 && intCONTACTCLEF == 0 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 )
      {
        chrono_marche_avant = millis();
        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 1 && intPORTE == 0 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0)
      {
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 1 && intCONTACTCLEF == 1 && intPORTE == 1)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 1  && intCONTACTCLEF == 1 && intPORTE == 0)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 0)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 0 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {



    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 1 && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);


  }
  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 0 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }
  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

  if (marche_avant_active == 1 )
  {
    delai_marche_avant = millis() - chrono_marche_avant;

  }
  if (marche_avant_active == 1   )

  {

    marche_arriere_active = 0;
    marcheavant1();

  }

  if ( marche_avant_active == 1  && SensorRead < 2.20  )
  {
    Stop();
    marche_avant_active = 0;

  }


  if (marche_arriere_active == 1  )
  {

    delai_marche_arriere = millis() - chrono_marche_arriere;

  }
  if (marche_arriere_active == 1)

  {
    marche_avant_active = 0;


    marchearriere1();

  }

  if ( marche_arriere_active == 1 && SensorRead > 3.10)
  {


    Stop();
    marche_arriere_active = 0;

  }
  chrono = millis();
}

void doubleclick()
{
  if (intAUTO == 1)
  {
    warning("Mode Auto");
  }
  if (intAUTO == 1 && intPORTE == 1 && intCONTACTCLEF == 0 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 )
      {
        chrono_marche_avant = millis();
        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 1 && intPORTE == 0 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0 )
      {
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 1 && intCONTACTCLEF == 1 && intPORTE == 1)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 1  && intCONTACTCLEF == 1 && intPORTE == 0)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 0)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 0 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {



    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 1 && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

   

  }
  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 0 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }


  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

  //Serial.print (F("SensorRead="));
  //Serial.println (SensorRead);


  //mesure("tension", SensorRead);




  if (marche_avant_active == 1 )
  {
    delai_marche_avant = millis() - chrono_marche_avant;

  }
  if (marche_avant_active == 1  && delai_marche_avant < 700 )

  {

    marche_arriere_active = 0;
    marcheavant1();

  }
  if ( marche_avant_active == 1  && delai_marche_avant <= 2500 && delai_marche_avant >= 700)
  {
    marche_arriere_active = 0;
    marcheavant2();

  }
  if ( marche_avant_active == 1  && delai_marche_avant > 2500 )
  {
    Stop();
    marche_avant_active = 0;

  }

  if (marche_arriere_active == 1  )
  {

    delai_marche_arriere = millis() - chrono_marche_arriere;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 900 )

  {
    marche_avant_active = 0;


    marchearriere1();

  }
  if ( marche_arriere_active == 1 && delai_marche_arriere >= 900)
  {
    marche_avant_active = 0;

    marchearriere2();

  }
  if ( marche_arriere_active == 1 && bpFINCOURSE == 0)
  {


    Stop();
    marche_arriere_active = 0;

  }
  chrono = millis();
}
void longclick()
{
  if (intAUTO == 1)
  {
    warning("Mode Auto");
  }
  if (intAUTO == 1 && intPORTE == 1 && intCONTACTCLEF == 0 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
      {
        chrono_marche_avant = millis();
        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 1 && intPORTE == 0 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 1 && intCONTACTCLEF == 1 && intPORTE == 1)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 1  && intCONTACTCLEF == 1 && intPORTE == 0)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 0)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 0 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {



    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 1 && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

   



  }
  if (intAUTO == 0 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 0 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }


  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

  //Serial.print (F("SensorRead="));
  //Serial.println (SensorRead);


  //mesure("tension", SensorRead);



  /* if (intCONTACTCLEF == 1 && bpFINCOURSE == 1)
    {
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("Retracter la marche avant de démarrer");

    }*/

  if (marche_avant_active == 1 )
  {
    delai_marche_avant = millis() - chrono_marche_avant;

  }
  if (marche_avant_active == 1  && delai_marche_avant < 900 )

  {

    marche_arriere_active = 0;
    marcheavant1();

  }
  if ( marche_avant_active == 1  && delai_marche_avant <= 2200 && delai_marche_avant >= 900)
  {
    marche_arriere_active = 0;
    marcheavant2();

  }
  if ( marche_avant_active == 1  && delai_marche_avant > 2200 )
  {
    Stop();
    marche_avant_active = 0;

  }

  if (marche_avant_active == 1  && delai_marche_avant < 2200 && SensorRead < 2.20)
  {
    chrono_marche_avant_obstacle = millis();
    marche_avant_active = 0;
    marche_avant_obstacle_active = 1;
  }

  if (marche_avant_obstacle_active == 1 )
  {
    delai_marche_avant_obstacle = millis() - chrono_marche_avant_obstacle;

    marchearriere1();

  }
  if ( marche_avant_obstacle_active == 1  && bpFINCOURSE == 0 )
  {

    Stop();
    marche_avant_obstacle_active = 0;
  }


  if (marche_arriere_active == 1  )
  {

    delai_marche_arriere = millis() - chrono_marche_arriere;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 1300 )

  {
    marche_avant_active = 0;


    marchearriere1();

  }
  if ( marche_arriere_active == 1 && delai_marche_arriere >= 1300)
  {
    marche_avant_active = 0;

    marchearriere2();

  }
  if ( marche_arriere_active == 1 && bpFINCOURSE == 0)
  {


    Stop();
    marche_arriere_active = 0;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 1800 && SensorRead > 2.95)
  {
    marche_arriere_active = 0;
    chrono_marche_arriere_obstacle = millis();
    marche_arriere_obstacle_active = 1;

  }

  if (marche_arriere_obstacle_active == 1)
  {
    delai_marche_arriere_obstacle = millis() - chrono_marche_arriere_obstacle;
    marcheavant1();

    delai_marche_arriere2 = delai_marche_arriere * 2;
  }
  if (marche_arriere_obstacle_active == 1 && delai_marche_arriere_obstacle >= (delai_marche_arriere2))
  {
    Stop();
    marche_arriere_obstacle_active = 0;
  }
  chrono = millis();
}


void setup()
{
  Serial.begin(9600);

  // Initialise le Timer 2 pour déclencher les interruptions à intervalle régulier
  TCCR2A = 0; //default
  TCCR2B = 0b00000110; // clk/256 est incrémenté toutes les 16uS
  TIMSK2 = 0b00000001; // TOIE2
  sei();               // autorise les interruptions

  
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(3, INPUT); // INTERRUPTEUR intPORTE
  pinMode(9, INPUT); // INTERRUPTEUR intCONTACTCLEF
  pinMode(8, INPUT); // INTERRUPTEUR intAUTO
  pinMode(6, INPUT); //  pin marche avant
  pinMode(12, INPUT); // pin marche arrière
  pinMode(7, INPUT); // pin FIN COURSE

 
  button.attachClick(simpleclick);
  button.attachDoubleClick(doubleclick);
  button.attachLongPressStart (longclick);
}

void loop()
{

  button.tick();

}

// routine d'interruption du timer
ISR (TIMER2_OVF_vect)
{
  // 256-6 --> 250X16uS = 4mS
  // Recharge le timer pour que la prochaine interruption se déclenche dans 4mS
  TCNT2 = 6;
  //================================//
  //je vais lire  toutes les entrées//
  //================================//
  bpMAV = digitalRead (6);// le bp av
  bpMAR = digitalRead (12);// le bp arr
  intPORTE = digitalRead (3);// le bp intPORTE
  intCONTACTCLEF = digitalRead (9);// le bp intCONTACTCLEF
  intAUTO = digitalRead (8);// le bp intAUTO
  bpFINCOURSE = digitalRead (7);// le bpFINCOURSE
  //================================//
  //================================//
  //================================//

}

C'est une belle usine à gaz, je pense qu'ils ne font pas mieux dans le nucléaire :rofl:
S'il ne fait pas ce que tu attends, c'est que les valeurs de tes divers flags ne sont pas celles que tu veux. Merci M. de La Pallice...
Il faut que tu trouves un moyen de simplifier tous tes tests pour t'y retrouver plus facilement.

Un exemple : tu crées une variable qui regroupe tous tes flags et tu la compares à toutes les valeurs possibles. Par exemple supposons 3 flags :

  • intAUTO
  • bpMAV
  • intPORTE

Tu crées : int test = intAUTO * 100 + bpMAV * 10 + intPORTE ;
test variera entre 0 et 999 (peut-être moins genre 111) et tu fais un switch / case :

switch (test) {
case 0 : 
// action si les 3 valent 0
break;
case 10 : 
// action si seul bpMAV  vaut 1
// etc
}

C'est un exemple en base 10, mais si tes flags valent uniquement 0 ou 1, il vaut mieux le faire en binaire : tu peux regrouper 32 flags dans un unsigned long

Postez le dessin de la machine à états

Je ne sais pas si c'est de ça que vous parlez.
je vous met aussi les 3 programme qui fonctionne séparément :

Programme1:

#define ENTREE_ANALOGIQUE 1
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#include <Fonts/FreeMono9pt7b.h>                    // Normal (en 9, 12, 18, et 24 pts)
#define nombreDePixelsEnLargeur 128         // Taille de l'écran OLED, en pixel, au niveau de sa largeur
#define nombreDePixelsEnHauteur 64          // Taille de l'écran OLED, en pixel, au niveau de sa hauteur
#define brocheResetOLED         -1          // Reset de l'OLED partagé avec l'Arduino (d'où la valeur à -1, et non un numéro de pin)
#define adresseI2CecranOLED     0x3C        // Adresse de "mon" écran OLED sur le bus i2c (généralement égal à 0x3C ou 0x3D)
#define IN1 10
#define IN2 5
Adafruit_SSD1306 ecranOLED(nombreDePixelsEnLargeur, nombreDePixelsEnHauteur, &Wire, brocheResetOLED);   // Le "Wire" indique qu'on travaille en I2C


volatile int bpMAV = 0;  //ON OFF
volatile int bpMAR = 0; //ON OFF
volatile int bpFINCOURSE = 0; //fin de course  du système
volatile int intPORTE = 0; // INTERRUPTEUR port
volatile int intCONTACTCLEF = 0; // INTERRUPTEUR clé
volatile int intAUTO = 0; // INTERRUPTEUR manuel/Auto

const int pourcent80 = 255;
const int pourcent20 = 50;
const int pourcent50 = 127;


int crono3 = 1300;
int cronall2 = 1000;

const char underscore[] = "__________";
const char egale[] = "=";
unsigned long chrono_marche_avant;
int marche_avant_active = 0;
unsigned long delai_marche_avant;
unsigned long chrono_marche_arriere;
int marche_arriere_active = 0;
unsigned long delai_marche_arriere;
int marche_avant_eau_active = 0;
unsigned long delai_marche_arriere_avant_eau ;
unsigned long chrono_marche_avant_eau ;
float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

int flag = 0;
int flag1 = 0;


const unsigned char myBitmap [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0c, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0x0f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0x27, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe2, 0x7e, 0x4f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe4, 0x7c, 0xcf, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc4, 0xe1, 0x8f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x88, 0x03, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf2, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xfc, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xc0, 0x7f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xc0, 0x02, 0x3f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfc, 0x3f, 0xff, 0xfd, 0x0f, 0xe0, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfe, 0x1f, 0xff, 0xfc, 0x3f, 0xf8, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xff, 0x0f, 0xff, 0xf8, 0x7f, 0xf8, 0x7f, 0xfb, 0x1f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x8f, 0xff, 0x07, 0xff, 0xf1, 0xff, 0xf8, 0x7f, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xc3, 0xfe, 0x83, 0xff, 0xe3, 0xff, 0xf0, 0xff, 0xfe, 0x07, 0x03, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xe0, 0xff, 0xe1, 0xff, 0xc7, 0xff, 0xf0, 0xff, 0xfc, 0x3f, 0xf1, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0xff, 0x80, 0xff, 0xc7, 0xff, 0xe1, 0xff, 0xfc, 0x7f, 0xd9, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x7f, 0x00, 0x3f, 0x8f, 0xff, 0xc1, 0xff, 0xf8, 0x7f, 0xf8, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x3f, 0x00, 0x00, 0x1f, 0xff, 0xc3, 0xff, 0xf8, 0xff, 0xf0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x00, 0x01, 0x00, 0x1f, 0xff, 0x87, 0xff, 0xf0, 0xff, 0xf1, 0x8f, 0xff, 0xff,
  0xff, 0xff, 0xfc, 0x00, 0x01, 0x84, 0x3f, 0xff, 0x87, 0xff, 0xf1, 0xff, 0xf1, 0xc7, 0xff, 0xff,
  0xff, 0xff, 0xfe, 0x00, 0x01, 0x80, 0x7f, 0xff, 0x0f, 0xff, 0xe1, 0xff, 0xe3, 0xe7, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x1f, 0xff, 0xe3, 0xff, 0xc3, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x80, 0xff, 0x00, 0xff, 0xfe, 0x1f, 0xff, 0xc3, 0xff, 0x87, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xc3, 0xff, 0xc0, 0xff, 0xfe, 0x3f, 0xff, 0xc7, 0xff, 0xc7, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xe1, 0xff, 0xc1, 0xff, 0xfe, 0x7f, 0xff, 0x87, 0xff, 0x8f, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf1, 0xff, 0x81, 0xff, 0xfc, 0xff, 0xff, 0x8f, 0xff, 0x8f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf8, 0x7e, 0x03, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0x0f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xfc, 0x18, 0x03, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0x1f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x3f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xfd, 0xff, 0xf8, 0x00, 0xf0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x80, 0x00, 0x7f, 0xf9, 0xff, 0xc0, 0x01, 0xe0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0x80, 0x00, 0x0f, 0x80, 0x3f, 0x00, 0x7f, 0xc1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x07, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x3f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x05, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x10, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// '106870349-vecteur-d-icône-de-porte-isolé-sur-fond-blanc-pour-la-conception-de-votre-application-web-et-mobile-', 128x64px
const unsigned char myBitmap1 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// 'istockphoto-1140967663-612x612', 128x64px
const unsigned char myBitmap2 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};


void setup()
{
  Serial.begin(9600);

  // Initialise le Timer 2 pour déclencher les interruptions à intervalle régulier
  TCCR2A = 0; //default
  TCCR2B = 0b00000110; // clk/256 est incrémenté toutes les 16uS
  TIMSK2 = 0b00000001; // TOIE2
  sei();               // autorise les interruptions

  ecranOLED.begin(SSD1306_SWITCHCAPVCC, adresseI2CecranOLED);

  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(2);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);

  ecranOLED.println(underscore);
  ecranOLED.println(F("GroupeInti"));
  ecranOLED.println(F("**ENJOY**"));
  ecranOLED.println(underscore);
  ecranOLED.display();
  ecranOLED.setTextSize(1);


  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(3, INPUT_PULLUP); // INTERRUPTEUR intPORTE
  pinMode(9, INPUT_PULLUP); // INTERRUPTEUR intCONTACTCLEF
  pinMode(8, INPUT_PULLUP); // INTERRUPTEUR intAUTO
  pinMode(6, INPUT_PULLUP); //  pin marche avant
  pinMode(12, INPUT_PULLUP); // pin marche arrière
  pinMode(7, INPUT_PULLUP); // pin FIN COURSE



}

void ecran (const char *valeur1, const char *ouvert_ferme, const char *valeur2, int etat2 , const char *valeur3, int etat3 , const char *valeur4, int etat4 )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur1);
  ecranOLED.print(egale);
  ecranOLED.println(ouvert_ferme);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur2);
  ecranOLED.print(egale);
  ecranOLED.println(etat2);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur3);
  ecranOLED.print(egale);
  ecranOLED.println(etat3);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur4);
  ecranOLED.print(egale);
  ecranOLED.println(etat4);
  ecranOLED.println(underscore);
  ecranOLED.display();


}

void mesure (const char *valeur, float tension )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur);
  ecranOLED.print(egale);
  ecranOLED.print(tension);
  ecranOLED.println(F(" V "));
  ecranOLED.display();
}

void warning (const char *warm  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(2);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.println(warm);
  ecranOLED.println(underscore);
  ecranOLED.display();


}
void image (const unsigned char *img  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap, 128, 64, 1);
  ecranOLED.display();


}
void image1 (const unsigned char *img1  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap1, 128, 64, 1);
  ecranOLED.display();


}
void image2 (const unsigned char *img2  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap2, 128, 64, 1);
  ecranOLED.display();


}


int marcheavant1 ()
{
  analogWrite(IN1, pourcent80);
  digitalWrite(IN2, LOW);

}

int marchearriere1 ()
{
  digitalWrite(IN1, LOW);
  analogWrite(IN2, pourcent80 );

}

int Stop ()
{
  digitalWrite(IN1, LOW);

  digitalWrite(IN2, LOW );

}


void loop()
{
  if (intAUTO == 0)
  {
    warning("Mode Auto");
  }
  if (intAUTO == 0 && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 )
      {

        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 0 && intPORTE == 1 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0)
      {

        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 0 && intCONTACTCLEF == 0 && intPORTE == 0)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);

        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 0  && intCONTACTCLEF == 0 && intPORTE == 1)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 1)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_arriere_active == 0 )
    {

      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_avant_active == 0 )
    {

      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 )
    {

      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {



    if (marche_avant_active == 0 )
    {
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 0 && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

    image(myBitmap1);



  }
  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_arriere_active == 0 )
    {

      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_avant_active == 0)
    {

      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }
  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output




  if (marche_avant_active == 1   )

  {
    marcheavant1();
    
  }

  if ( marche_avant_active == 1  && SensorRead < 2.00  )
    {
   
    Stop();
    marche_avant_active = 0;
    
    }

  if (marche_arriere_active == 1)

  {
    marche_avant_active = 0;


    marchearriere1();

  }

  if ( marche_arriere_active == 1 && bpFINCOURSE == 1)
  {

    Stop();
    marche_arriere_active = 0;

  }

}

// routine d'interruption du timer
ISR (TIMER2_OVF_vect)
{
  // 256-6 --> 250X16uS = 4mS
  // Recharge le timer pour que la prochaine interruption se déclenche dans 4mS
  TCNT2 = 6;
  //================================//
  //je vais lire  toutes les entrées//
  //================================//
  bpMAV = digitalRead (6);// le bp av
  bpMAR = digitalRead (12);// le bp arr
  intPORTE = digitalRead (3);// le bp intPORTE
  intCONTACTCLEF = digitalRead (9);// le bp intCONTACTCLEF
  intAUTO = digitalRead (8);// le bp intAUTO
  bpFINCOURSE = digitalRead (7);// le bpFINCOURSE
  //================================//
  //================================//
  //================================//

}

Programme 2 :

#define ENTREE_ANALOGIQUE 1
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#include <Fonts/FreeMono9pt7b.h>                    // Normal (en 9, 12, 18, et 24 pts)
#define nombreDePixelsEnLargeur 128         // Taille de l'écran OLED, en pixel, au niveau de sa largeur
#define nombreDePixelsEnHauteur 64          // Taille de l'écran OLED, en pixel, au niveau de sa hauteur
#define brocheResetOLED         -1          // Reset de l'OLED partagé avec l'Arduino (d'où la valeur à -1, et non un numéro de pin)
#define adresseI2CecranOLED     0x3C        // Adresse de "mon" écran OLED sur le bus i2c (généralement égal à 0x3C ou 0x3D)
#define IN1 10
#define IN2 5
Adafruit_SSD1306 ecranOLED(nombreDePixelsEnLargeur, nombreDePixelsEnHauteur, &Wire, brocheResetOLED);   // Le "Wire" indique qu'on travaille en I2C


volatile int bpMAV = 0;  //ON OFF
volatile int bpMAR = 0; //ON OFF
volatile int bpFINCOURSE = 0; //fin de course  du système
volatile int intPORTE = 0; // INTERRUPTEUR port
volatile int intCONTACTCLEF = 0; // INTERRUPTEUR clé
volatile int intAUTO = 0; // INTERRUPTEUR manuel/Auto

const int pourcent80 = 255;
const int pourcent20 = 50;
const int pourcent50 = 127;


int crono3 = 1300;
int cronall2 = 1000;

const char underscore[] = "__________";
const char egale[] = "=";
unsigned long chrono_marche_avant;
int marche_avant_active = 0;
unsigned long delai_marche_avant;
unsigned long chrono_marche_arriere;
int marche_arriere_active = 0;
unsigned long delai_marche_arriere;
unsigned long delai_marche_arriere2;

int obstacle_marche_avant = 0;
int obstacle_marche_arriere = 0;
unsigned long chrono_porte_ouverte ;
int porte_ouverte_active = 0;
unsigned long delai_porte_ouverte;

float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

int flag = 0;
int flag1 = 0;


const unsigned char myBitmap [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0c, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0x0f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0x27, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe2, 0x7e, 0x4f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe4, 0x7c, 0xcf, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc4, 0xe1, 0x8f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x88, 0x03, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf2, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xfc, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xc0, 0x7f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xc0, 0x02, 0x3f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfc, 0x3f, 0xff, 0xfd, 0x0f, 0xe0, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfe, 0x1f, 0xff, 0xfc, 0x3f, 0xf8, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xff, 0x0f, 0xff, 0xf8, 0x7f, 0xf8, 0x7f, 0xfb, 0x1f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x8f, 0xff, 0x07, 0xff, 0xf1, 0xff, 0xf8, 0x7f, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xc3, 0xfe, 0x83, 0xff, 0xe3, 0xff, 0xf0, 0xff, 0xfe, 0x07, 0x03, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xe0, 0xff, 0xe1, 0xff, 0xc7, 0xff, 0xf0, 0xff, 0xfc, 0x3f, 0xf1, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0xff, 0x80, 0xff, 0xc7, 0xff, 0xe1, 0xff, 0xfc, 0x7f, 0xd9, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x7f, 0x00, 0x3f, 0x8f, 0xff, 0xc1, 0xff, 0xf8, 0x7f, 0xf8, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x3f, 0x00, 0x00, 0x1f, 0xff, 0xc3, 0xff, 0xf8, 0xff, 0xf0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x00, 0x01, 0x00, 0x1f, 0xff, 0x87, 0xff, 0xf0, 0xff, 0xf1, 0x8f, 0xff, 0xff,
  0xff, 0xff, 0xfc, 0x00, 0x01, 0x84, 0x3f, 0xff, 0x87, 0xff, 0xf1, 0xff, 0xf1, 0xc7, 0xff, 0xff,
  0xff, 0xff, 0xfe, 0x00, 0x01, 0x80, 0x7f, 0xff, 0x0f, 0xff, 0xe1, 0xff, 0xe3, 0xe7, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x1f, 0xff, 0xe3, 0xff, 0xc3, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x80, 0xff, 0x00, 0xff, 0xfe, 0x1f, 0xff, 0xc3, 0xff, 0x87, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xc3, 0xff, 0xc0, 0xff, 0xfe, 0x3f, 0xff, 0xc7, 0xff, 0xc7, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xe1, 0xff, 0xc1, 0xff, 0xfe, 0x7f, 0xff, 0x87, 0xff, 0x8f, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf1, 0xff, 0x81, 0xff, 0xfc, 0xff, 0xff, 0x8f, 0xff, 0x8f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf8, 0x7e, 0x03, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0x0f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xfc, 0x18, 0x03, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0x1f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x3f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xfd, 0xff, 0xf8, 0x00, 0xf0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x80, 0x00, 0x7f, 0xf9, 0xff, 0xc0, 0x01, 0xe0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0x80, 0x00, 0x0f, 0x80, 0x3f, 0x00, 0x7f, 0xc1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x07, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x3f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x05, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x10, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// '106870349-vecteur-d-icône-de-porte-isolé-sur-fond-blanc-pour-la-conception-de-votre-application-web-et-mobile-', 128x64px
const unsigned char myBitmap1 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// 'istockphoto-1140967663-612x612', 128x64px
const unsigned char myBitmap2 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};


void setup()
{
  Serial.begin(9600);

  // Initialise le Timer 2 pour déclencher les interruptions à intervalle régulier
  TCCR2A = 0; //default
  TCCR2B = 0b00000110; // clk/256 est incrémenté toutes les 16uS
  TIMSK2 = 0b00000001; // TOIE2
  sei();               // autorise les interruptions

  ecranOLED.begin(SSD1306_SWITCHCAPVCC, adresseI2CecranOLED);

  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(2);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);

  ecranOLED.println(underscore);
  ecranOLED.println(F("GroupeInti"));
  ecranOLED.println(F("**ENJOY**"));
  ecranOLED.println(underscore);
  ecranOLED.display();
  ecranOLED.setTextSize(1);


  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(3, INPUT_PULLUP); // INTERRUPTEUR intPORTE
  pinMode(9, INPUT_PULLUP); // INTERRUPTEUR intCONTACTCLEF
  pinMode(8, INPUT_PULLUP); // INTERRUPTEUR intAUTO
  pinMode(6, INPUT_PULLUP); //  pin marche avant
  pinMode(12, INPUT_PULLUP); // pin marche arrière
  pinMode(7, INPUT_PULLUP); // pin FIN COURSE



}

void ecran (const char *valeur1, const char *ouvert_ferme, const char *valeur2, int etat2 , const char *valeur3, int etat3 , const char *valeur4, int etat4 )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur1);
  ecranOLED.print(egale);
  ecranOLED.println(ouvert_ferme);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur2);
  ecranOLED.print(egale);
  ecranOLED.println(etat2);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur3);
  ecranOLED.print(egale);
  ecranOLED.println(etat3);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur4);
  ecranOLED.print(egale);
  ecranOLED.println(etat4);
  ecranOLED.println(underscore);
  ecranOLED.display();


}

void mesure (const char *valeur, float tension )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur);
  ecranOLED.print(egale);
  ecranOLED.print(tension);
  ecranOLED.println(F(" V "));
  ecranOLED.display();
}

void warning (const char *warm  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(2);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.println(warm);
  ecranOLED.println(underscore);
  ecranOLED.display();


}
void image (const unsigned char *img  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap, 128, 64, 1);
  ecranOLED.display();


}
void image1 (const unsigned char *img1  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap1, 128, 64, 1);
  ecranOLED.display();


}
void image2 (const unsigned char *img2  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap2, 128, 64, 1);
  ecranOLED.display();


}


int marcheavant1 ()
{
  analogWrite(IN1, pourcent80);
  digitalWrite(IN2, LOW);

}
int marcheavant2 ()
{
  analogWrite(IN1, pourcent20);
  digitalWrite(IN2, LOW);

}
int marchearriere1 ()
{
  digitalWrite(IN1, LOW);
  analogWrite(IN2, pourcent80 );

}
int marchearriere2 ()
{
  digitalWrite(IN1, LOW);
  analogWrite(IN2, pourcent20 );

}
int Stop ()
{
  digitalWrite(IN1, LOW);

  digitalWrite(IN2, LOW );

}


void loop()
{
  if (intAUTO == 0)
  {
    warning("Mode Auto"); 
  }
  if (intAUTO == 0 && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 )
      {
        chrono_marche_avant = millis();
        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 0 && intPORTE == 1 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0 )
      {
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 0 && intCONTACTCLEF == 0 && intPORTE == 0)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 0  && intCONTACTCLEF == 0 && intPORTE == 1)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 )
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 1)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {



    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 0 && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

    image(myBitmap1);



  }
  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_arriere_active == 0 )
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 0 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 )
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }


  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

  //Serial.print (F("SensorRead="));
  //Serial.println (SensorRead);


  //mesure("tension", SensorRead);




  if (marche_avant_active == 1 )
  {
    delai_marche_avant = millis() - chrono_marche_avant;

  }
  if (marche_avant_active == 1  && delai_marche_avant < 700 )

  {

    marche_arriere_active = 0;
    marcheavant1();

  }
  if ( marche_avant_active == 1  && delai_marche_avant <= 2500 && delai_marche_avant >= 700)
  {
    marche_arriere_active = 0;
    marcheavant2();

  }
  if ( marche_avant_active == 1  && delai_marche_avant > 2500 )
  {
    Stop();
    marche_avant_active = 0;

  }
  
  if (marche_arriere_active == 1  )
  {

    delai_marche_arriere = millis() - chrono_marche_arriere;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 900 )

  {
    marche_avant_active = 0;


    marchearriere1();

  }
  if ( marche_arriere_active == 1 && delai_marche_arriere >= 900)
  {
    marche_avant_active = 0;

    marchearriere2();

  }
  if ( marche_arriere_active == 1 && bpFINCOURSE == 1)
  {


    Stop();
    marche_arriere_active = 0;

  }
  

}

// routine d'interruption du timer
ISR (TIMER2_OVF_vect)
{
  // 256-6 --> 250X16uS = 4mS
  // Recharge le timer pour que la prochaine interruption se déclenche dans 4mS
  TCNT2 = 6;
  //================================//
  //je vais lire  toutes les entrées//
  //================================//
  bpMAV = digitalRead (6);// le bp av
  bpMAR = digitalRead (12);// le bp arr
  intPORTE = digitalRead (3);// le bp intPORTE
  intCONTACTCLEF = digitalRead (9);// le bp intCONTACTCLEF
  intAUTO = digitalRead (8);// le bp intAUTO
  bpFINCOURSE = digitalRead (7);// le bpFINCOURSE
  //================================//
  //================================//
  //================================//

}

Programme 3:

#define ENTREE_ANALOGIQUE 1
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#include <Fonts/FreeMono9pt7b.h>                    // Normal (en 9, 12, 18, et 24 pts)
#define nombreDePixelsEnLargeur 128         // Taille de l'écran OLED, en pixel, au niveau de sa largeur
#define nombreDePixelsEnHauteur 64          // Taille de l'écran OLED, en pixel, au niveau de sa hauteur
#define brocheResetOLED         -1          // Reset de l'OLED partagé avec l'Arduino (d'où la valeur à -1, et non un numéro de pin)
#define adresseI2CecranOLED     0x3C        // Adresse de "mon" écran OLED sur le bus i2c (généralement égal à 0x3C ou 0x3D)
#define IN1 10
#define IN2 5
Adafruit_SSD1306 ecranOLED(nombreDePixelsEnLargeur, nombreDePixelsEnHauteur, &Wire, brocheResetOLED);   // Le "Wire" indique qu'on travaille en I2C


volatile int bpMAV = 0;  //ON OFF
volatile int bpMAR = 0; //ON OFF
volatile int bpFINCOURSE = 0; //fin de course  du système
volatile int intPORTE = 0; // INTERRUPTEUR port
volatile int intCONTACTCLEF = 0; // INTERRUPTEUR clé
volatile int intAUTO = 0; // INTERRUPTEUR manuel/Auto

const int pourcent80 = 204;
const int pourcent20 = 50;
const int pourcent50 = 127;


int crono3 = 1300;
int cronall2 = 1000;

const char underscore[] = "__________";
const char egale[] = "=";
unsigned long chrono_marche_avant;
int marche_avant_active = 0;
unsigned long delai_marche_avant;
unsigned long chrono_marche_arriere;
int marche_arriere_active = 0;
unsigned long delai_marche_arriere;
unsigned long delai_marche_arriere2;

int obstacle_marche_avant = 0;
int obstacle_marche_arriere = 0;
unsigned long chrono_porte_ouverte ;
int porte_ouverte_active = 0;
unsigned long delai_porte_ouverte;
int marche_arriere_obstacle_active = 0;
unsigned long delai_marche_arriere_obstacle;
unsigned long chrono_marche_arriere_obstacle;
int marche_avant_obstacle_active = 0;
unsigned long delai_marche_avant_obstacle;
unsigned long chrono_marche_avant_obstacle;

float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

int flag = 0;
int flag1 = 0;


const unsigned char myBitmap [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0c, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0x0f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0x27, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe2, 0x7e, 0x4f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe4, 0x7c, 0xcf, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc4, 0xe1, 0x8f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x88, 0x03, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf2, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xfc, 0x3f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xc0, 0x7f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xc0, 0x02, 0x3f, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfc, 0x3f, 0xff, 0xfd, 0x0f, 0xe0, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xfe, 0x1f, 0xff, 0xfc, 0x3f, 0xf8, 0x3f, 0xf9, 0x8f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x1f, 0xff, 0x0f, 0xff, 0xf8, 0x7f, 0xf8, 0x7f, 0xfb, 0x1f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x8f, 0xff, 0x07, 0xff, 0xf1, 0xff, 0xf8, 0x7f, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xc3, 0xfe, 0x83, 0xff, 0xe3, 0xff, 0xf0, 0xff, 0xfe, 0x07, 0x03, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xe0, 0xff, 0xe1, 0xff, 0xc7, 0xff, 0xf0, 0xff, 0xfc, 0x3f, 0xf1, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0xff, 0x80, 0xff, 0xc7, 0xff, 0xe1, 0xff, 0xfc, 0x7f, 0xd9, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x7f, 0x00, 0x3f, 0x8f, 0xff, 0xc1, 0xff, 0xf8, 0x7f, 0xf8, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x3f, 0x00, 0x00, 0x1f, 0xff, 0xc3, 0xff, 0xf8, 0xff, 0xf0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xf8, 0x00, 0x01, 0x00, 0x1f, 0xff, 0x87, 0xff, 0xf0, 0xff, 0xf1, 0x8f, 0xff, 0xff,
  0xff, 0xff, 0xfc, 0x00, 0x01, 0x84, 0x3f, 0xff, 0x87, 0xff, 0xf1, 0xff, 0xf1, 0xc7, 0xff, 0xff,
  0xff, 0xff, 0xfe, 0x00, 0x01, 0x80, 0x7f, 0xff, 0x0f, 0xff, 0xe1, 0xff, 0xe3, 0xe7, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x1f, 0xff, 0xe3, 0xff, 0xc3, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x80, 0xff, 0x00, 0xff, 0xfe, 0x1f, 0xff, 0xc3, 0xff, 0x87, 0xe3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xc3, 0xff, 0xc0, 0xff, 0xfe, 0x3f, 0xff, 0xc7, 0xff, 0xc7, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xe1, 0xff, 0xc1, 0xff, 0xfe, 0x7f, 0xff, 0x87, 0xff, 0x8f, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf1, 0xff, 0x81, 0xff, 0xfc, 0xff, 0xff, 0x8f, 0xff, 0x8f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xf8, 0x7e, 0x03, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0x0f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xfc, 0x18, 0x03, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0x1f, 0xfc, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x3f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xf8, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xfd, 0xff, 0xf8, 0x00, 0xf0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x80, 0x00, 0x7f, 0xf9, 0xff, 0xc0, 0x01, 0xe0, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xfe, 0x1f, 0x80, 0x00, 0x0f, 0x80, 0x3f, 0x00, 0x7f, 0xc1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x07, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0x1f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x3f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x1f, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x05, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x10, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// '106870349-vecteur-d-icône-de-porte-isolé-sur-fond-blanc-pour-la-conception-de-votre-application-web-et-mobile-', 128x64px
const unsigned char myBitmap1 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x30, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// 'istockphoto-1140967663-612x612', 128x64px
const unsigned char myBitmap2 [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};


void setup()
{
  Serial.begin(9600);

  // Initialise le Timer 2 pour déclencher les interruptions à intervalle régulier
  TCCR2A = 0; //default
  TCCR2B = 0b00000110; // clk/256 est incrémenté toutes les 16uS
  TIMSK2 = 0b00000001; // TOIE2
  sei();               // autorise les interruptions

  ecranOLED.begin(SSD1306_SWITCHCAPVCC, adresseI2CecranOLED);

  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(2);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);

  ecranOLED.println(underscore);
  ecranOLED.println(F("GroupeInti"));
  ecranOLED.println(F("**ENJOY**"));
  ecranOLED.println(underscore);
  ecranOLED.display();
  ecranOLED.setTextSize(1);


  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(3, INPUT_PULLUP); // INTERRUPTEUR intPORTE
  pinMode(9, INPUT_PULLUP); // INTERRUPTEUR intCONTACTCLEF
  pinMode(8, INPUT_PULLUP); // INTERRUPTEUR intAUTO
  pinMode(6, INPUT_PULLUP); //  pin marche avant
  pinMode(12, INPUT_PULLUP); // pin marche arrière
  pinMode(7, INPUT_PULLUP); // pin FIN COURSE



}

void ecran (const char *valeur1, const char *ouvert_ferme, const char *valeur2, int etat2 , const char *valeur3, int etat3 , const char *valeur4, int etat4 )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur1);
  ecranOLED.print(egale);
  ecranOLED.println(ouvert_ferme);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur2);
  ecranOLED.print(egale);
  ecranOLED.println(etat2);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur3);
  ecranOLED.print(egale);
  ecranOLED.println(etat3);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur4);
  ecranOLED.print(egale);
  ecranOLED.println(etat4);
  ecranOLED.println(underscore);
  ecranOLED.display();


}

void mesure (const char *valeur, float tension )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(1);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.print(valeur);
  ecranOLED.print(egale);
  ecranOLED.print(tension);
  ecranOLED.println(F(" V "));
  ecranOLED.display();
}

void warning (const char *warm  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setTextSize(2);
  ecranOLED.setCursor(0, 0);
  ecranOLED.setTextColor(SSD1306_WHITE);
  ecranOLED.println(underscore);
  ecranOLED.println(warm);
  ecranOLED.println(underscore);
  ecranOLED.display();


}
void image (const unsigned char *img  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap, 128, 64, 1);
  ecranOLED.display();


}
void image1 (const unsigned char *img1  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap1, 128, 64, 1);
  ecranOLED.display();


}
void image2 (const unsigned char *img2  )
{
  ecranOLED.clearDisplay();
  ecranOLED.setCursor(0, 0);
  ecranOLED.drawBitmap(1, 1,  myBitmap2, 128, 64, 1);
  ecranOLED.display();


}


int marcheavant1 ()
{
  analogWrite(IN1, pourcent80);
  digitalWrite(IN2, LOW);

}
int marcheavant2 ()
{
  analogWrite(IN1, pourcent20);
  digitalWrite(IN2, LOW);

}
int marchearriere1 ()
{
  digitalWrite(IN1, LOW);
  analogWrite(IN2, pourcent80 );

}
int marchearriere2 ()
{
  digitalWrite(IN1, LOW);
  analogWrite(IN2, pourcent20 );

}
int Stop ()
{
  digitalWrite(IN1, LOW);

  digitalWrite(IN2, LOW );

}


void loop()
{
  if (intAUTO == 0)
  {
    warning("Mode Auto"); 
  }
  if (intAUTO == 0 && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

      if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
      {
        chrono_marche_avant = millis();
        marche_avant_active = 1;
        ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 2;
    }
  }

  if (intAUTO == 0 && intPORTE == 1 )
  {

    if (flag1 == 2)
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
        ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);
      }

      flag1 = 3;
    }

  }
  if (intAUTO == 0 && intCONTACTCLEF == 0 && intPORTE == 0)
  {
    if ( flag1 == 3 || flag1 == 2 )
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
        chrono_marche_arriere = millis();
        marche_arriere_active = 1;
      }


      flag1 = 4;
    }
  }
  if (intAUTO == 0  && intCONTACTCLEF == 0 && intPORTE == 1)
  {
    if ( flag1 == 4)
    {

      if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
      {
        ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
      }
      flag1 = 5;
    }

  }

  Serial.println (flag1);

  if (intAUTO == 1)

  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 2 || flag1 == 3 || flag1 == 4 || flag1 == 5)
    {
      warning("   Mode     Manuel");
      delay(500);
    }
    flag1 = 6;
  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 6)

    {

      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 0);

    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 1  )
  {

    if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 1 && intCONTACTCLEF == 1)
  {

    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 1 && intCONTACTCLEF == 0  )
  {


    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "FERMER", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 0  )
  {



    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 1, "BP AV", 0, "BP AR", 0);
    }
  }

  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 0 && intPORTE == 0 && intCONTACTCLEF == 0  )
  {

    ecran ("NO", "1", "NO", 1, "NO", 1, "NO", 1);

    image(myBitmap1);



  }
  if (intAUTO == 1 && bpMAV == 0 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_arriere_active == 0 || marche_avant_obstacle_active == 0)
    {
      chrono_marche_avant = millis();
      marche_avant_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 1, "BP AR", 0);
    }

  }

  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 0  && intPORTE == 0 && intCONTACTCLEF == 1  )
  {


    if (marche_avant_active == 0 || marche_arriere_obstacle_active == 0)
    {
      chrono_marche_arriere = millis();
      marche_arriere_active = 1;
      ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 1);
    }

  }
  if (intAUTO == 1 && bpMAV == 1 && bpMAR == 1  && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    ecran ("PORTE", "OUVERTE", "CLEF", 0, "BP AV", 0, "BP AR", 0);

  }


  float SensorRead = analogRead(A2) * 5.0 / 1023.0;  //We read the sensor output

  //Serial.print (F("SensorRead="));
  //Serial.println (SensorRead);


  //mesure("tension", SensorRead);



  /* if (intCONTACTCLEF == 0 && bpFINCOURSE == 0)
    {
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("  STOP!");
     delay(200);
     warning("");
     delay(200);
     warning("Retracter la marche avant de démarrer");

    }*/

  if (marche_avant_active == 1 )
  {
    delai_marche_avant = millis() - chrono_marche_avant;

  }
  if (marche_avant_active == 1  && delai_marche_avant < 1000 )

  {

    marche_arriere_active = 0;
    marcheavant1();

  }
  if ( marche_avant_active == 1  && delai_marche_avant <= 2200 && delai_marche_avant >= 1000)
  {
    marche_arriere_active = 0;
    marcheavant2();

  }
  if ( marche_avant_active == 1  && delai_marche_avant > 2200 )
  {
    Stop();
    marche_avant_active = 0;

  }

  if (marche_avant_active == 1  && delai_marche_avant < 2200 && SensorRead < 2.10)
  {
    chrono_marche_avant_obstacle = millis();
    marche_avant_active = 0;
    marche_avant_obstacle_active = 1;
  }

  if (marche_avant_obstacle_active == 1 )
  {
    delai_marche_avant_obstacle = millis() - chrono_marche_avant_obstacle;

    marchearriere1();

  }
  if ( marche_avant_obstacle_active == 1  && bpFINCOURSE == 1 )
  {

    Stop();
    marche_avant_obstacle_active = 0;
  }


  if (marche_arriere_active == 1  )
  {

    delai_marche_arriere = millis() - chrono_marche_arriere;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 1300 )

  {
    marche_avant_active = 0;


    marchearriere1();

  }
  if ( marche_arriere_active == 1 && delai_marche_arriere >= 1300)
  {
    marche_avant_active = 0;

    marchearriere2();

  }
  if ( marche_arriere_active == 1 && bpFINCOURSE == 1)
  {


    Stop();
    marche_arriere_active = 0;

  }
  if (marche_arriere_active == 1  && delai_marche_arriere < 1800 && SensorRead > 3.00)
  {
    marche_arriere_active = 0;
    chrono_marche_arriere_obstacle = millis();
    marche_arriere_obstacle_active = 1;

  }

  if (marche_arriere_obstacle_active == 1)
  {
    delai_marche_arriere_obstacle = millis() - chrono_marche_arriere_obstacle;
    marcheavant1();

    delai_marche_arriere2 = delai_marche_arriere * 2;
  }
  if (marche_arriere_obstacle_active == 1 && delai_marche_arriere_obstacle >= (delai_marche_arriere2))
  {
    Stop();
    marche_arriere_obstacle_active = 0;
  }

}

// routine d'interruption du timer
ISR (TIMER2_OVF_vect)
{
  // 256-6 --> 250X16uS = 4mS
  // Recharge le timer pour que la prochaine interruption se déclenche dans 4mS
  TCNT2 = 6;
  //================================//
  //je vais lire  toutes les entrées//
  //================================//
  bpMAV = digitalRead (6);// le bp av
  bpMAR = digitalRead (12);// le bp arr
  intPORTE = digitalRead (3);// le bp intPORTE
  intCONTACTCLEF = digitalRead (9);// le bp intCONTACTCLEF
  intAUTO = digitalRead (8);// le bp intAUTO
  bpFINCOURSE = digitalRead (7);// le bpFINCOURSE
  //================================//
  //================================//
  //================================//

}

Bonsoir,
finalement j'ai régler mon problème merci

Dans un forum, quand on trouve soi-même la solution au problème posé, on explique comment on a fait.
Ca sert à payer ceux qui ont phosphoré sur les problèmes des autres.

Non je parlais de dessin comme dans mon tuto. Votre code a trop de drapeaux (flags)

oui désolé j'aller le faire, la solution était juste de mettre un booléen qui renvoi a mon programme qui doit se trouvé dans la loop pour qu'il puisse tourner.
merci a tous pour votre aide, ça m'a donner des idées.

Je ne suis pas vraiment douer pour les dessin, je pense que ce que j'ai fait représente la même chose que les dessin sur votre tuto.
et merci votre tuto m'a bien aider.

Pour la partie externe mais quand je vois ça dans le code

if (intAUTO == 0 && intPORTE == 0 && intCONTACTCLEF == 1 )
  {
    if (flag1 == 0 || flag1 == 1 || flag1 == 5 || flag1 == 3 || flag1 == 4 || flag1 == 6)
    {

Je me dis qu’il doit y avoir plus simple pour représenter l’état

oui c'est possible c'est juste ma réflexion personnel, je vais voir ça mardi pour pouvoir le tester sur place.

Bonjour J-M-L

Merci pour votre tuto, j'ai un projet c'est un système de comptage de passager dans les bus,
je vais réaliser ça avec des cellules photoélectrique. en fait je vais utiliser deux cellules pour savoir le sens d'entré/sortie. pour le moment je ne sais pas appliquée votre tuto sur ma situation, j'ai plusieurs cas possible et il faut gérer le temps de chaque situation, par exemple si c'est un monté il faut avoir :
LOW LOW (rien)
HIGH LOW (capteur de gauche en détection)
HIGH HIGH (dans la zone d'incertitude)
LOW HIGH (capteur de droite en détection)
LOW LOW (rien)
et le contraire pour la descente.
alors dans un cas du bus, si quelqu'un veut monter il va activer le premier capteur, mais un passager du bus a activer le deuxième capteur parce que il veut descendre avant commet gérer ça dans une machine d'état, ce sont des cas aléatoires. selon vous monsieur est ce que c'est faisable avec, sinon est ce que vous avez un conseil pour me donner une piste.

Merci d'avance

Bonsoir @AMS

Créez votre propre post pour votre question

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.