Advertisement
microrobotics

Baby Orangutan B-328 Robot Controller

Apr 3rd, 2023
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. 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.
  3.  
  4. 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.
  5.  
  6. 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.
  7. */
  8.  
  9. #include <OrangutanMotors.h>
  10.  
  11. OrangutanMotors motors;
  12.  
  13. void setup() {
  14.   // Initialize the Baby Orangutan motor controller
  15.   motors.setSpeeds(0, 0); // Set both motors to 0 speed
  16. }
  17.  
  18. void loop() {
  19.   // Move the robot forward for 1 second
  20.   motors.setSpeeds(200, 200); // Set both motors to forward with speed 200
  21.   delay(1000);
  22.  
  23.   // Stop the robot for 0.5 seconds
  24.   motors.setSpeeds(0, 0); // Set both motors to 0 speed
  25.   delay(500);
  26.  
  27.   // Turn the robot left for 1 second
  28.   motors.setSpeeds(-200, 200); // Set left motor to reverse with speed 200, and right motor to forward with speed 200
  29.   delay(1000);
  30.  
  31.   // Stop the robot for 0.5 seconds
  32.   motors.setSpeeds(0, 0); // Set both motors to 0 speed
  33.   delay(500);
  34.  
  35.   // Turn the robot right for 1 second
  36.   motors.setSpeeds(200, -200); // Set left motor to forward with speed 200, and right motor to reverse with speed 200
  37.   delay(1000);
  38.  
  39.   // Stop the robot for 0.5 seconds
  40.   motors.setSpeeds(0, 0); // Set both motors to 0 speed
  41.   delay(500);
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement