Last active
December 8, 2018 12:01
-
-
Save ypelletier/20d74ba2ab26c3de8516f3d7e1764482 to your computer and use it in GitHub Desktop.
Deux moteurs à courant continu contrôlés par une carte Arduino avec un module L9110S.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************** | |
Deux moteurs à courant continu contrôlés par une | |
carte Arduino avec un module L9110S. | |
http://electroniqueamateur.blogspot.com/2017/12/controle-de-deux-moteurs-avec-l9110s-et.html | |
****************************************************/ | |
#define moteur1A 3 | |
#define moteur1B 9 | |
#define moteur2A 10 | |
#define moteur2B 11 | |
int vitesse = 255; // 0 à 255 | |
void setup() { | |
} | |
void loop() { | |
// les deux moteurs tournent en marche avant, | |
// à haute vitesse | |
//moteur 1 | |
vitesse = 255; | |
analogWrite(moteur1A, 0); | |
analogWrite(moteur1B, vitesse); | |
//moteur 2 | |
analogWrite(moteur2A, 0); | |
analogWrite(moteur2B, vitesse); | |
delay(3000); // on attend 3 secondes | |
// on inverse le sens de rotation du moteur 1, | |
// et le moteur 2 continue dans le même sens qu'avant, | |
// avec une vitesse réduite. | |
//moteur 1 | |
vitesse = 255; | |
analogWrite(moteur1A, vitesse); | |
analogWrite(moteur1B, 0); | |
//moteur 2 | |
vitesse = 100; | |
analogWrite(moteur2A, 0); | |
analogWrite(moteur2B, vitesse); | |
delay(2000); // on attend 2 secondes | |
// le moteur 1 s'arrête complètement, et | |
// le moteur 2 part en sens inverse à faible vitesse | |
//moteur 1 | |
analogWrite(moteur1A, 0); | |
analogWrite(moteur1B, 0); | |
//moteur 2 | |
vitesse = 100; | |
analogWrite(moteur2A, vitesse); | |
analogWrite(moteur2B, 0); | |
delay(3000); // pendant 3 secondes | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment