Motors and Drivetrain


Lets get started on the double gearbox and motor. First open up the double gearbox kit and check that you have all the needed parts.


You have several different options as far as assembly goes. There are 4 different gear ratios you can use. I started with a gear ratio of 38.2:1, this means the small motor shaft will turn roughly 38 times for every time the drive gear on the track turns. Once I got to testing the motors with the tracks mounted I could tell it was too low of a gear ration, the tracks would barely move at low speed and then quickly came up to a fast speed. I changed to 344.2:1 and the speed range was much better, but the top speed was pretty low. I would recommend you start with 114.7:1 or 344.2:1, but feel free to experiment (more on gear ratios later). Any setting should be able to make tracks move under no load, to at least see if things are working.


Now to get those motors turning get familiar with the Arduino motor shield.

The Arduino Uno by itself is capable of controlling a motor through any of its PWM (pulse width modulation) ports which are ports ( 3, 5, 6, 9, 10, 11), but the board by itself cannot supply enough current for our robot. The Uno is rated to deliver 40 mA per port (5V) and total of 200 mA for the whole board. This won’t be enough for our robot. The motor shield uses up 8 ports from our Uno, and provides 2 output channels ( A and B ) one for each motor, with these we can get up to 2 amps per channel. The following pins are used. ( ).

Function                    Ch. A              Ch. B
Direction                    D12                D13
PWM                          D3                 D11
Brake                        D9                 D8
Current Sensing              A0                 A1

We cannot use these ports for the remote control, ultrasonic sensor, or any function other than driving the motors, but there are still plenty of free ports to do those things.
Lets start with something simple and just get a single motor working. I always try to think in the context of an application add a little something interesting when figuring out how to do something. Lets use our motor to demonstrate the stroboscopic effect. All we need is a piece of heavy paper like an index card or postcard and some glue or tape. One example of the stroboscopic effect is is known as the wagon wheel effect , which is an optical illusion where a wheel or propeller of some kind appears to spin at a frequency different from the actual rotation frequency, which you have probably observed looking at another vehicle’s tire while driving on a highway.


Start with a postcard and draw some lines on it like so.


Then cut the two pieces out and glue them to the motor so that light and dark regions are opposite to one another. I used hot melt glue and it worked just fine, scotch tape should work fine too, this is just for fun, it doesn’t need to be strong or last for long.

The hot melt glue dries pretty fast, and the pieces of heavy paper are so light it can be tricky to glue them together, I found it worked best to first tape the paper to the table, then lift one piece, place the glue and then press them together using something beside your finger. ( so you don’t burn it). After this, use the glue or tape again to attach the little propeller to the motor shaft, you’ll need to devise some way of holding the motor, I used a clamp and it worked great, if you don’t have a clamp, you can probably just get by with wedging it between two heavy books.

In order to observe this effect we want to hook up the motor and then gradually increase the speed every 2 seconds or so. First attach the motor shield and hook up the motor to channel A. You can do this with only the usb cable attached, it should provide enough power . I went ahead and attached the battery pack since we’ll be using it for the robot. Note that we need 5 to 12V to run the motor shield, these 4 AA batteries will produce about 6V, but they won’t run it for very long when we use it to run two motors and power the robot.

In order to set the speed of the motor, we need to call analogWrite() passing pin3, and the speed we want to run the motor at, this value can be any value between 0 and 255, with 255 corresponding to the max speed. ( )

      analogWrite(3, 255); //Spins the motor on Channel A

We also need to establish the direction we want the motor to turn ( this also depends on how you have it wired). This is done with digitalWrite(), the direction for channel A is set with pin 12. The direction the motor spins doesn’t really matter for this.

     digitalWrite(12, HIGH); //Establishes forward direction of Channel A

and we need to disengage the brake for channel A, this is also done with digitalWrite().

     digitalWrite(9, LOW);   //Disengage the Brake for Channel A

Here is the complete code I used to gradually increase the speed and observe the stroboscopic effect.

     void setup() 
        //Setup Channel A
        pinMode(12, OUTPUT); //Initiates Motor Channel A pin
        pinMode(9, OUTPUT); //Initiates Brake Channel A pin

     void loop()
        for(int i=60; i < 150; i++)
           //forward @ full speed
           digitalWrite(12, HIGH); //Establishes forward direction of Channel A
           digitalWrite(9, LOW);   //Disengage the Brake for Channel A
           analogWrite(3, i);   //Spins the motor on Channel A 

Here is what you should see, the effect is best seen around 0:30, and around 1:10

Lets jump ahead in time a little bit , and see run this program that gradually increases the speed of the motor on the robot with one of the tracks assembled. I did this to get an idea of the speed range that we would get at the different gear ratios. The first video shows the lower gear ratio, notice that it does not move at all at first, then moves, but sputters a bit, by the end of the video, the track is moving pretty fast (probably too fast). The second video is of the higher gear ratio, notice that it starts moving immediately, and has a smooth acceleration throughout. The same code is used here as above, the only difference here is that the speed that is given to analogWrite(3, i) is from 0 to 255.

gear ratio 38.2:1

gear ratio 344.2:1

We now know enough to operate the motors for our robot. Lets move on to setting up remote control.

Intro->SOS->Chassis Assembly->Motors & Drive-train->Arduino-Remote Control->Assembly->Ultrasonic Sensor->Final Testing

 Posted by at 3:50 pm

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



Time limit is exhausted. Please reload CAPTCHA.