#include <Stepper.h>
#include <AFMotor.h>
#include <Wire.h> 
#include "rgb_lcd.h" 
 
rgb_lcd lcd; 
 
 
int enA  = 3;  
int enB  = 11;  
int dirA = 12;  
int dirB = 13;  
 
 
const int stepsPerRevolution = 400;  
 
Stepper myStepper(stepsPerRevolution, dirA, dirB);            
AF_Stepper motor1(400,1);
AF_Stepper motor2(400,2);
 
 
void forwardstep1()
{
    motor1.onestep(FORWARD,SINGLE);
}
void backwardstep1()
 
{
    motor1.onestep(BACKWARD,SINGLE);
}
 
void forwardstep2()
{
    motor2.onestep(FORWARD,SINGLE);
}
void backwardstep2()
{
    motor2.onestep(BACKWARD,SINGLE);
}
 
 
 
void setup() {
 
 
 
 lcd.begin(16, 2);
 
  myStepper.setSpeed(60);  //  vitesse 60 tours par minute
 
 
  pinMode(enA, OUTPUT);
  digitalWrite (enA, HIGH);
 
  pinMode(enB, OUTPUT);
  digitalWrite (enB, HIGH);  
 
  motor1.setSpeed(10);  //  vitesse 10 tours par minute
  motor2.setSpeed(30);  //  vitesse 30 tours par minute
 
}
 
void loop() {
 
 
//ETAPE 1 : DESCENTE ET PRELEVEMENT + MONTEE 
lcd.setCursor(0,0); 
lcd.print("DESCENTE"); 
lcd.setCursor(0,1); 
lcd.print("..."); 
motor2.step(4000,FORWARD,SINGLE);            // DESCENTE
delay(2000);
lcd.clear();
 
lcd.setCursor(0,0); 
lcd.print("PRELEVEMENT"); 
lcd.setCursor(0,1); 
lcd.print("1.5 mL BLEU"); 
myStepper.step(stepsPerRevolution*8);        // PRELEVEMENT 1.5 mL
delay(2000);
lcd.clear();
 
lcd.setCursor(0,0); 
lcd.print("MONTEE"); 
lcd.setCursor(0,1); 
lcd.print("..."); 
motor2.step(4000,BACKWARD,SINGLE);            // MONTEE
delay(2000);
lcd.clear();
 
 
 
//ETAPE 2 : ROTATION 90° 
lcd.setCursor(0,0); 
lcd.print("ROTATION"); 
lcd.setCursor(0,1); 
lcd.print("..."); 
motor1.step(100,FORWARD,SINGLE);             // ROTATAION 90°
delay(2000);
lcd.clear(); 
 
 
 
//ETAPE 3 : DESCENTE ET LARGUAGE + REMONTEE
lcd.setCursor(0,0); 
lcd.print("DESCENTE"); 
lcd.setCursor(0,1); 
lcd.print("...");  
motor2.step(4000,FORWARD,SINGLE);           // DESCENTE 
delay(2000);
lcd.clear(); 
 
lcd.setCursor(0,0); 
lcd.print("LARGUAGE BLEU"); 
lcd.setCursor(0,1); 
lcd.print("...");
myStepper.step(-stepsPerRevolution*8);       // LARGUAGE 1.5 mL
delay(2000); 
lcd.clear(); 
 
lcd.setCursor(0,0); 
lcd.print("MONTEE"); 
lcd.setCursor(0,1); 
lcd.print("...");
motor2.step(4000,BACKWARD,SINGLE);            // MONTEE
delay(2000);
lcd.clear(); 
 
 
 
//ETAPE 4 : ROTATION 90°
lcd.setCursor(0,0); 
lcd.print("ROTATION"); 
lcd.setCursor(0,1); 
lcd.print("..."); 
motor1.step(100,FORWARD,SINGLE);             //ROTATION 90°
delay(2000);
lcd.clear();  
 
 
 
//ETAPE 5 : DESCENTE ET PRELEVEMENT + MONTEE 
lcd.setCursor(0,0); 
lcd.print("DESCENTE"); 
lcd.setCursor(0,1); 
lcd.print("..."); 
motor2.step(4000,FORWARD,SINGLE);            // DESCENTE
delay(2000);
lcd.clear();
 
lcd.setCursor(0,0); 
lcd.print("PRELEVEMENT"); 
lcd.setCursor(0,1); 
lcd.print("1.5 mL JAUNE"); 
myStepper.step(stepsPerRevolution*8);        // PRELEVEMENT 1.5 mL
delay(2000);
lcd.clear();
 
lcd.setCursor(0,0); 
lcd.print("MONTEE"); 
lcd.setCursor(0,1); 
lcd.print("..."); 
motor2.step(4000,BACKWARD,SINGLE);            // MONTEE
delay(2000);
lcd.clear();
 
 
 
//ETAPE 6 : ROTATION 90°
lcd.setCursor(0,0); 
lcd.print("ROTATION"); 
lcd.setCursor(0,1); 
lcd.print("..."); 
motor1.step(100,BACKWARD,SINGLE);             //ROTATION 90°
delay(2000);
lcd.clear();  
 
 
 
//ETAPE 7 : DESCENTE ET LARGUAGE + REMONTEE
lcd.setCursor(0,0); 
lcd.print("DESCENTE"); 
lcd.setCursor(0,1); 
lcd.print("...");  
motor2.step(4000,FORWARD,SINGLE);           // DESCENTE 
delay(2000);
lcd.clear(); 
 
lcd.setCursor(0,0); 
lcd.print("LARGUAGE JAUNE"); 
lcd.setCursor(0,1); 
lcd.print("...");
myStepper.step(-stepsPerRevolution*8);       // LARGUAGE 1.5 mL
delay(2000); 
lcd.clear(); 
 
lcd.setCursor(0,0); 
lcd.print("MONTEE"); 
lcd.setCursor(0,1); 
lcd.print("...");
motor2.step(4000,BACKWARD,SINGLE);            // MONTEE
delay(2000);
lcd.clear(); 
 
lcd.setCursor(0,0); 
lcd.print("BLEU + JAUNE ="); 
lcd.setCursor(0,1); 
lcd.print("BLEULAUNE");
delay(200000);
 
 
 
}