Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

1.

Moving Forward And Backward

Step 1: First of all, launch the Arduino IDE that you have just
installed. Copy & paste this code into your Arduino IDE.
#include "CytronMakerSumo.h"

void setup() {
MakerSumo.begin();
}

void loop() {
MakerSumo.setMotorSpeed(MOTOR_L, 50); // Left motor forward at speed 50.
MakerSumo.setMotorSpeed(MOTOR_R, 50); // Right motor forward at speed 50.
delay(3000); // Delay for 3 seconds.

MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).


MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.

MakerSumo.setMotorSpeed(MOTOR_L, -50); // Left motor backward at speed 50.


MakerSumo.setMotorSpeed(MOTOR_R, -50); // Right motor backward at speed 50.
delay(3000); // Delay for 3 seconds.

MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).


MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.
}
Step 2: To include Cytron Maker Sumo Library. Go to Tools >
Manage Libraries...

Step 3: Search for "maker sumo", then click 'Install".


Step 4: Before we upload the program to your robot, it is a good
practice to save all our program files. Go to File > Save As

Step 5: Create a new folder called "Sumo Robot". (you are free to
decide where to save the folder)
Step 6: Name the program you want to save as "Basic
Navigation".

So you have saved your first program as "Basic Navigation" under


the folder of "Sumo Robot". When you create your next program
later, you can name it anything you want but save it under the
same Sumo Robot folder.
Step 7: Now, you can upload the program to your robot. Click the
"upload" button located at the top bar of the Arduino IDE.

Make sure you have connected the USB cable on the PC and your
board. You will see "Done uploading" appear at the bottom when
it is done.

Step 8: Unplug the USB cable from your robot. Then turn on the
power, your robot should be moving forward for 3 seconds before
it stops for 1 second then it will move backward for 3 seconds.
And it will keep repeating if you don't turn it off.
Step 9: Try to change the speed of your motor to 150 and reduce
the delay to 1000. Then upload it to your robot again.
#include "CytronMakerSumo.h"

void setup() {
MakerSumo.begin();
}

void loop() {
MakerSumo.setMotorSpeed(MOTOR_L, 150); // Left motor forward at speed 150.
MakerSumo.setMotorSpeed(MOTOR_R, 150); // Right motor forward at speed 150.
delay(1000); // Delay for 1 second.

MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).


MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.

MakerSumo.setMotorSpeed(MOTOR_L, -150); // Left motor backward at speed 150.


MakerSumo.setMotorSpeed(MOTOR_R, -150); // Right motor backward at speed 150.
delay(1000); // Delay for 1 second.

MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).


MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.
}
Step 10: Unplug the USB cable and turn on your robot.

You may notice now that your robot isn't running forward/
backward in a straight line. Don't worry, it is completely normal
that your robot is not moving straight or behaves differently from
mine or from your friends because every robot is unique just like
you and me.

We will discuss this issue later but we want to bring your attention
to these 2 parameters: speed and delay. From the 2 programs we
made earlier, you should realize that in order to change the robot
speed, you can change the second value inside function:
MakerSumo.setMotorSpeed(MOTOR_L, 150);

Where 0 is stop, 255 is maximum speed and negative value is


reverse.

To control how long you want a certain command to execute, you


can change the value in function:
delay(1000);

The delay is in millisecond. 1000 millisecond = 1 second.


Why doesn'tmy robot moves straight?

There are several reasons led to this problem:

1. The floor or the map is not flat. This will cause one of the
wheels not touching the ground and spinning.

2. The mounting of the motors is not straight or not aligned. You


can realign the motors by loosening the motor bracket.

3. The weight distribution of the robot does not balance mainly


caused by the battery. So you can consider to stick the battery at
the center position or add some weight on the motor which the
wheel is spinning.

4. The internal resistance of the motor is not consistent so even if


you apply the same speed to 2 different motors, they won't be
running at the same speed. To solve this problem, you can
slightly adjust the speed in your program for an individual motor.
E.g.: If your robot always runs toward the right side, you can
either reduce the speed of the left motor or increase the speed of
the right motor until they are running straight.
MakerSumo.setMotorSpeed(MOTOR_L, 130);
MakerSumo.setMotorSpeed(MOTOR_R, 150);

or
MakerSumo.setMotorSpeed(MOTOR_L, 150);
MakerSumo.setMotorSpeed(MOTOR_R, 180);

You might also like