Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This code demonstrates how to use the Baby Orangutan dual motor controller to control the movement of a robot. The OrangutanMotors library is used to control the motor speeds.
- To use this code, connect the motors to the Baby Orangutan dual motor controller according to the wiring diagram provided in the product documentation. The motor controller should be powered with a suitable power source for your motors (usually 6-12V DC). The code sets the speeds of the left and right motors using the setSpeeds() function of the OrangutanMotors library. Positive values set the motors to move forward, negative values set the motors to move backward, and 0 sets the motors to stop. You can adjust the speed values to control the speed and direction of the motors.
- Note that the motor speed and direction may vary depending on the type and specifications of your motors, and the mechanical design of your robot.
- */
- #include <OrangutanMotors.h>
- OrangutanMotors motors;
- void setup() {
- // Initialize the Baby Orangutan motor controller
- motors.setSpeeds(0, 0); // Set both motors to 0 speed
- }
- void loop() {
- // Move the robot forward for 1 second
- motors.setSpeeds(200, 200); // Set both motors to forward with speed 200
- delay(1000);
- // Stop the robot for 0.5 seconds
- motors.setSpeeds(0, 0); // Set both motors to 0 speed
- delay(500);
- // Turn the robot left for 1 second
- motors.setSpeeds(-200, 200); // Set left motor to reverse with speed 200, and right motor to forward with speed 200
- delay(1000);
- // Stop the robot for 0.5 seconds
- motors.setSpeeds(0, 0); // Set both motors to 0 speed
- delay(500);
- // Turn the robot right for 1 second
- motors.setSpeeds(200, -200); // Set left motor to forward with speed 200, and right motor to reverse with speed 200
- delay(1000);
- // Stop the robot for 0.5 seconds
- motors.setSpeeds(0, 0); // Set both motors to 0 speed
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement