Modification du code driver DC + Ajout code de test
This commit is contained in:
66
Moteur DC/Test/Test_Moteur_DC/Test_Moteur_DC.ino
Normal file
66
Moteur DC/Test/Test_Moteur_DC/Test_Moteur_DC.ino
Normal file
@@ -0,0 +1,66 @@
|
||||
int motor1Pin1 = 9; // pin 2 (Input 1) du L293D
|
||||
int motor1Pin2 = 10; // pin 7 (Input 2) du L293D
|
||||
int enablePin = 11; // pin 1 (Enable 1) du L293D
|
||||
|
||||
void setup() {
|
||||
// set all the other pins you're using as outputs:
|
||||
pinMode(motor1Pin1, OUTPUT);
|
||||
pinMode(motor1Pin2, OUTPUT);
|
||||
pinMode(enablePin, OUTPUT);
|
||||
|
||||
// Mettre la broche Enable a high comme ca le moteur tourne
|
||||
digitalWrite(enablePin, HIGH);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Le moteur tourne dans un sens
|
||||
digitalWrite(motor1Pin1, LOW); // mettre pin 2 a 293D low
|
||||
digitalWrite(motor1Pin2, HIGH); // mettre pin 7 a L293D high
|
||||
|
||||
delay( 100 );
|
||||
|
||||
// Le moteur tourne dans l'autre sens
|
||||
digitalWrite(motor1Pin1, HIGH); // Mettre pin 2 a L293D high
|
||||
digitalWrite(motor1Pin2, LOW); // Mettre pin 7 a L293D low
|
||||
|
||||
delay( 100 );
|
||||
|
||||
// Le moteur tourne dans un sens
|
||||
digitalWrite(motor1Pin1, LOW); // mettre pin 2 a 293D low
|
||||
digitalWrite(motor1Pin2, HIGH); // mettre pin 7 a L293D high
|
||||
|
||||
delay( 50 );
|
||||
|
||||
// Le moteur tourne dans l'autre sens
|
||||
digitalWrite(motor1Pin1, HIGH); // Mettre pin 2 a L293D high
|
||||
digitalWrite(motor1Pin2, LOW); // Mettre pin 7 a L293D low
|
||||
|
||||
delay( 50 );
|
||||
|
||||
// Le moteur tourne dans un sens
|
||||
digitalWrite(motor1Pin1, LOW); // mettre pin 2 a 293D low
|
||||
digitalWrite(motor1Pin2, HIGH); // mettre pin 7 a L293D high
|
||||
|
||||
delay( 100 );
|
||||
|
||||
// Le moteur tourne dans l'autre sens
|
||||
digitalWrite(motor1Pin1, HIGH); // Mettre pin 2 a L293D high
|
||||
digitalWrite(motor1Pin2, LOW); // Mettre pin 7 a L293D low
|
||||
|
||||
delay( 100 );
|
||||
|
||||
|
||||
// Le moteur tourne dans un sens
|
||||
digitalWrite(motor1Pin1, LOW); // mettre pin 2 a 293D low
|
||||
digitalWrite(motor1Pin2, HIGH); // mettre pin 7 a L293D high
|
||||
|
||||
delay( 200 );
|
||||
|
||||
// Le moteur tourne dans l'autre sens
|
||||
digitalWrite(motor1Pin1, HIGH); // Mettre pin 2 a L293D high
|
||||
digitalWrite(motor1Pin2, LOW); // Mettre pin 7 a L293D low
|
||||
|
||||
delay( 200 );
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user