Étape 5 :
Il s’agit d’un programme de suiveur de ligne simple
int leftInput = 3 ;
int rightInput = 2 ;
int leftMotor = 1 ;
int rightMotor = 0 ;
int leftValue = 0 ;
int rightValue = 0 ;
void setup() {}
Serial.Begin(9600) ;
pinMode (leftMotor, sortie) ;
pinMode (rightMotor, sortie) ;
}
void loop() {}
leftValue = digitalRead(leftInput) ;
rightValue = digitalRead(rightInput) ;
Si (leftValue == HIGH & & rightValue == HIGH)
{
digitalWrite (leftMotor, HIGH) ; digitalWrite (rightMotor, HIGH) ;
} else {}
Si (leftValue == LOW & & rightValue == HIGH)
{
digitalWrite (leftMotor, basse) ; digitalWrite (rightMotor, HIGH) ;
} else {}
Si (leftValue == HIGH & & rightValue == faible)
{
digitalWrite (rightMotor, basse) ;
digitalWrite (leftMotor, HIGH) ;
} else {}
Si (leftValue == LOW & & rightValue == faible)
{
digitalWrite (rightMotor, basse) ;
digitalWrite (leftMotor, basse) ;
}}
}
}}