Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define L9110S_B_IA 11 // D10 --> Motor B Input A --> MOTOR B +
- #define L9110S_B_IB 10 // D11 --> Motor B Input B --> MOTOR B -
- #define L9110S_A_IA 8 // D9 --> Motor A Input A --> MOTOR A +
- #define L9110S_A_IB 9 // D8 --> Motor A Input B --> MOTOR A -
- // functional connections
- #define MOTOR_B_PWM L9110S_B_IA // Motor B PWM Speed
- #define MOTOR_B_DIR L9110S_B_IB // Motor B Direction
- #define MOTOR_A_PWM L9110S_A_IA // Motor A PWM Speed
- #define MOTOR_A_DIR L9110S_A_IB // Motor A Direction
- // the actual values for "fast" and "slow" depend on the motorqww666 q b7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,k888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888((((((((((((((((((((((((((999888888888888uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu , . qq q
- #define PWM_SLOW 50 // arbitrary slow speed PWM duty cycle
- #define PWM_FAST 200 // arbitrary fast speed PWM duty cycle
- #define DIR_DELAY 500 // brief delay for abrupt motor changes
- // defines pins numbers
- const int trigPin = 4;
- const int echoPin = 3;
- // defines variables
- long duration;
- int distance;
- void setup(){
- Serial.begin( 9600 );
- pinMode( MOTOR_B_DIR, OUTPUT );
- pinMode( MOTOR_B_PWM, OUTPUT );
- digitalWrite( MOTOR_B_DIR, LOW );
- digitalWrite( MOTOR_B_PWM, LOW );
- pinMode( MOTOR_A_DIR, OUTPUT );
- pinMode( MOTOR_A_PWM, OUTPUT );
- digitalWrite( MOTOR_A_DIR, LOW );
- digitalWrite( MOTOR_A_PWM, LOW );
- pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
- pinMode(echoPin, INPUT); // Sets the echoPin as an Input
- }
- void loop(){
- // set the motor speed and direction
- digitalWrite( MOTOR_B_DIR, LOW); // direction = forward
- analogWrite( MOTOR_B_PWM, 255-PWM_FAST ); // PWM speed = fast
- digitalWrite( MOTOR_A_DIR, HIGH ); // direction = forward
- analogWrite( MOTOR_A_PWM, 255-PWM_FAST ); // PWM speed = fast
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement