Advertisement
safwan092

Untitled

Apr 16th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. //This Arduino code is developed by I Lab
  2. //Hit the SUBSCRIBE button for following our tutorial on arduino.
  3. //You Tube Channel ID: https://www.youtube.com/c/IngenieroLab?sub_confirmation=1.
  4. //Follow our facebook page: https://www.facebook.com/ingenierorobotico
  5.  
  6. //BTS7960 motor driver sketch
  7.  
  8. int R_IS = 2;
  9. int R_EN = 5;
  10. int R_PWM = 10;
  11. int L_IS = 3;
  12. int L_EN = 4;
  13. int L_PWM = 9;
  14.  
  15. void setup() {
  16. // put your setup code here, to run once:
  17. pinMode(R_IS, OUTPUT);
  18. pinMode(R_EN, OUTPUT);
  19. pinMode(R_PWM, OUTPUT);
  20. pinMode(L_IS, OUTPUT);
  21. pinMode(L_EN, OUTPUT);
  22. pinMode(L_PWM, OUTPUT);
  23. digitalWrite(R_IS, LOW);
  24. digitalWrite(L_IS, LOW);
  25. digitalWrite(R_EN, HIGH);
  26. digitalWrite(L_EN, HIGH);
  27. }
  28.  
  29. void loop() {
  30. // put your main code here, to run repeatedly:
  31. int i;
  32. for (i = 0; i <= 255; i = i + 10) { //clockwise rotation
  33. analogWrite(R_PWM, i);
  34. analogWrite(L_PWM, 0);
  35. delay(500);
  36. }
  37. delay(500);
  38. for (i = 0; i <= 255; i = i + 10) { //counter clockwise rotation
  39. analogWrite(R_PWM, 0);
  40. analogWrite(L_PWM, i);
  41. delay(500);
  42. }
  43. delay(500);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement