
int motor1_enablePin = 10; //pwm
int motor1_in1Pin = 3;
int motor1_in2Pin = 2;
 
int motor2_enablePin = 11;//pwm
int motor2_in1Pin = 5;
int motor2_in2Pin = 6;


//Fonction qui set le moteur1
void SetMotor1(int speed, boolean reverse)
{
  analogWrite(motor1_enablePin, speed);
  digitalWrite(motor1_in1Pin, ! reverse);
  digitalWrite(motor1_in2Pin, reverse);
}
 
//Fonction qui set le moteur2
void SetMotor2(int speed, boolean reverse)
{
  analogWrite(motor2_enablePin, speed);
  digitalWrite(motor2_in1Pin, ! reverse);
  digitalWrite(motor2_in2Pin, reverse);
}


void setup()
{

  pinMode(motor1_in1Pin, OUTPUT);
  pinMode(motor1_in2Pin, OUTPUT);
  pinMode(motor1_enablePin, OUTPUT);
  pinMode(motor2_in1Pin, OUTPUT);
  pinMode(motor2_in2Pin, OUTPUT);
  pinMode(motor2_enablePin, OUTPUT);
}


void loop(){
    for(int i = 50; i < 255; i++){
        SetMotor1(i, true);
        delay(100);
    }
    for(int i = 50; i < 255; i++){
        SetMotor1(i, false);
        delay(100);
    }
    SetMotor1(0, true);
    for(int i = 50; i < 255; i++){
        SetMotor2(i, true);
        delay(100);
    }
    for(int i = 50; i < 255; i++){
        SetMotor2(i, false);
        delay(100);
    }
    SetMotor2(0, true);

}
