Advertisement
carterchilly

ARDUINO SECOND CODE

Nov 12th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. //Truth Table for Motor Control
  2. // ENA ENB IN1 IN2 IN3 IN4 Description
  3. // HIGH HIGH HIGH LOW LOW HIGH Car is going forward
  4. // HIGH HIGH LOW HIGH HIGH LOW Car is running back
  5. // HIGH HIGH LOW HIGH LOW HIGH Car is turning left
  6. // HIGH HIGH HIGH LOW HIGH LOW Car is turning right
  7. // HIGH HIGH LOW LOW LOW LOW Car is stopped
  8. // HIGH HIGH HIGH HIGH HIGH HIGH Car is stopped
  9. // LOW LOW N/A N/A N/A N/A Car is stopped
  10.  
  11.  
  12.  
  13. #include <Arduino.h>
  14. // define L298n module IO pin
  15. #define ENB 5
  16. #define IN1 7
  17. #define IN2 8
  18. #define IN3 9
  19. #define IN4 11
  20. #define ENA 6
  21.  
  22.  
  23. void forward() {
  24. digitalWrite(ENA, HIGH);
  25. digitalWrite(ENB, HIGH);
  26. digitalWrite(IN1, HIGH);
  27. digitalWrite(IN2, LOW);
  28. digitalWrite(IN3, LOW);
  29. digitalWrite(IN4, HIGH);
  30. Serial.println("Forward");
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement