Outils pour utilisateurs

Outils du site


exercices:arduino

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
exercices:arduino [2026/10/08 09:22] – [Code C++] adminexercices:arduino [2026/10/08 15:33] (Version actuelle) – [Code Block] admin
Ligne 282: Ligne 282:
 ====== Arduino moteur 2 sens Via L293D ====== ====== Arduino moteur 2 sens Via L293D ======
  
-{{ :exercices:h-bridge-working-motor-direction-control-animation.gif?direct&600 |}}+== Doc L293D == 
 + 
 +{{ :exercices:ds_l293d.pdf |Notice technique L293D EN}} 
 + 
 +[[https://lastminuteengineers.com/l293d-dc-motor-arduino-tutorial/|Tuto l293D et Arduino ]] 
 + 
 +[[start:arduino:l293d|l293d]] 
 + 
 +{{ :exercices:h-bridge-working-motor-direction-control-animation.gif?direct&400 |}} 
 + 
 +{{ :exercices:l293d-dual-h-bridge-motor-driver-ic-pinout.png?direct&600 |}} 
 + 
 +== Plans == 
 + 
 +{{ :exercices:arduinomoteurccl293d.png?direct&800 |}} 
 + 
 +{{ :exercices:capture_d_ecran_du_2026-10-08_12-20-02.png?direct&800 |}} 
 + 
 +== Code Block == 
 + 
 +**Tinkercad** 
 +{{ :exercices:capture_d_ecran_du_2026-10-08_14-12-27.png?direct&800 |}} 
 + 
 +**Vittascience** 
 +{{ :exercices:capture_d_ecran_du_2026-10-08_15-30-38.png?direct&900 |}} 
 + 
 +== Code C++ == 
 + 
 +<code c arduinomoteurL293D.ino> 
 +// Motor A connections 
 +int enA = 9; 
 +int in1 = 8; 
 +int in2 = 7; 
 + 
 +void setup() { 
 +  // Set all the motor control pins to outputs 
 +  pinMode(enA, OUTPUT); 
 +  pinMode(in1, OUTPUT); 
 +  pinMode(in2, OUTPUT); 
 +   
 + 
 +  // Turn off motors - Initial state 
 +  digitalWrite(in1, LOW); 
 +  digitalWrite(in2, LOW); 
 +  
 +} 
 + 
 +void loop() { 
 +  directionControl(); 
 +  delay(1000); 
 +  speedControl(); 
 +  delay(1000); 
 +} 
 + 
 +// This function lets you control spinning direction of motors 
 +void directionControl() { 
 +  // Set motors to maximum speed 
 +  digitalWrite(enA, HIGH); 
 +   
 + 
 +  // Turn on motor A  
 +  digitalWrite(in1, HIGH); 
 +  digitalWrite(in2, LOW); 
 +  delay(2000); 
 + 
 +  // Now change motor directions 
 +  digitalWrite(in1, LOW); 
 +  digitalWrite(in2, HIGH); 
 +  delay(2000); 
 + 
 +  // Turn off motors 
 +  digitalWrite(in1, LOW); 
 +  digitalWrite(in2, LOW); 
 + } 
 + 
 +// This function lets you control speed of the motors 
 +void speedControl() { 
 +  // Turn on motors 
 +  digitalWrite(in1, LOW); 
 +  digitalWrite(in2, HIGH); 
 +   
 + 
 +  // Accelerate from zero to maximum speed 
 +  for (int i = 0; i < 256; i++) { 
 +    analogWrite(enA, i); 
 +    delay(20); 
 +  } 
 + 
 +  // Decelerate from maximum speed to zero 
 +  for (int i = 255; i >= 0; --i) { 
 +    analogWrite(enA, i); 
 +    delay(20); 
 +  } 
 + 
 +  // Now turn off motors 
 +  digitalWrite(in1, LOW); 
 +  digitalWrite(in2, LOW); 
 +} 
 +</code> 
/home/chanteri/www/fablab37110/data/attic/exercices/arduino.1791444120.txt.gz · Dernière modification : de admin