Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. #define L9110S_B_IA 11 // D10 --> Motor B Input A --> MOTOR B +
  2. #define L9110S_B_IB 10 // D11 --> Motor B Input B --> MOTOR B -
  3.  
  4. #define L9110S_A_IA 8 // D9 --> Motor A Input A --> MOTOR A +
  5. #define L9110S_A_IB 9 // D8 --> Motor A Input B --> MOTOR A -
  6.  
  7. // functional connections
  8. #define MOTOR_B_PWM L9110S_B_IA // Motor B PWM Speed
  9. #define MOTOR_B_DIR L9110S_B_IB // Motor B Direction
  10.  
  11. #define MOTOR_A_PWM L9110S_A_IA // Motor A PWM Speed
  12. #define MOTOR_A_DIR L9110S_A_IB // Motor A Direction
  13.  
  14.  
  15. // the actual values for "fast" and "slow" depend on the motorqww666 q b7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,k888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888((((((((((((((((((((((((((999888888888888uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu , . qq q
  16. #define PWM_SLOW 50 // arbitrary slow speed PWM duty cycle
  17. #define PWM_FAST 200 // arbitrary fast speed PWM duty cycle
  18. #define DIR_DELAY 500 // brief delay for abrupt motor changes
  19.  
  20.  
  21. // defines pins numbers
  22. const int trigPin = 4;
  23. const int echoPin = 3;
  24. // defines variables
  25. long duration;
  26. int distance;
  27.  
  28. void setup(){
  29. Serial.begin( 9600 );
  30. pinMode( MOTOR_B_DIR, OUTPUT );
  31. pinMode( MOTOR_B_PWM, OUTPUT );
  32. digitalWrite( MOTOR_B_DIR, LOW );
  33. digitalWrite( MOTOR_B_PWM, LOW );
  34.  
  35. pinMode( MOTOR_A_DIR, OUTPUT );
  36. pinMode( MOTOR_A_PWM, OUTPUT );
  37. digitalWrite( MOTOR_A_DIR, LOW );
  38. digitalWrite( MOTOR_A_PWM, LOW );
  39.  
  40. pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  41. pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  42.  
  43.  
  44. }
  45.  
  46. void loop(){
  47.  
  48. // set the motor speed and direction
  49. digitalWrite( MOTOR_B_DIR, LOW); // direction = forward
  50. analogWrite( MOTOR_B_PWM, 255-PWM_FAST ); // PWM speed = fast
  51.  
  52. digitalWrite( MOTOR_A_DIR, HIGH ); // direction = forward
  53. analogWrite( MOTOR_A_PWM, 255-PWM_FAST ); // PWM speed = fast
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement