Robotics‎ > ‎


To control the Robo-kart, you can use almost the same code used to remote control a NanoMouse/LogoMouse via Bluetooth.

Controlling DC Motors

One change you need to make is adding code to control DC motors using a motor driver.
  • Learn to Use Motor Drivers
Once you've worked through the tutorial, you'll need to add the MotorDriver library to your Bluetooth Remote program. Then replace any code related to servo motors with code that uses your motor driver library.

Start by swapping the line that includes the Servo library with the MotorDriver library you just created.
#include <Servo.h> #include "MotorDriver.h"

Then, change how the motor objects are created:
Servo leftMotor; MotorDriver<5,6> leftMotor;
Servo rightMotor; MotorDriver<9,10> rightMotor;

Since your new library defines has a constructor function that specifies which pins are used to control each motor when you create the motor objects, you can now delete the lines of code that attached your servos to pins:

The manner in which we send commands to the motors is different too. Instead of using the writeMicroseconds function to send values above and below 1500 (the stop signal for servo motors), we can now use the drive function in the library we created and send values between 0 and 255 to go forwards and 0 to -255 to go backwards.
    leftServo.writeMicroseconds(1500-msg[0]*5);[0] * 2.55);
    rightServo.writeMicroseconds(1500+msg[1]*5);[1] * 2.55);

That will get the Robo-kart moving, but we will have to make another change. Test the modifications you've made and see how they work with the Robo-kart's wheels propped off the ground.


The NanoMouse/LogoMouse robots are small and light weight so they don't have much inertia. Making them change direction instantly is not a big deal. However, the Robo-kart is very heavy and has a lot of inertia. Asking the motors to change directions instantly is likely to break something. We need to make changes gradually.

If yo have not yet completed the sensors section of the NanoMouse curriculum, do so now. Once you understand how to implement smoothing, apply the technique here to smooth the values for each motor so that any changes take a full second to implement.

4 Pack Oodles Monster 55 Inch x 3.5 Inch Jumbo Swimming Pool Noodle $24.88