After assembling the robot successfully, let’s start the most exciting journey: games!
With the basic operation of the Arduino IDE and the circuit theory of the car previously, you should already have a general understanding of the robot car. Next, let’s move on to the specific applications and the corresponding actions of the robot.
In subsequent operations, you need to know some basic buttons on the main board:
Power switch: Switch on and off the robot.
Start button: To start the program, especially in the line following function.
Reset button: To reset the master board.
Open the RollbotMicro folder downloaded and unzipped previously in Chapter 3 Software Operation. You can see the following folders inside:
5.1 Display the Sensor Signal Intensity on OLED
This experiment is to display the collected sensor data on the OLED screen. Here it is just applied for simple display. Later in the line following experiment, we will use the intensity to control the direction of the car.
1) FindRollbotMicroOLED.inounderRollbot\Arduino Code\RollbotMicro\RollbotMicroOLED, open it andupload to the RollbotMicro.
2) Click Tools -> Board, select Arduino/Genuino Uno
And then, click Tools -> Port, select COM7(depending on your actual situation).
3) Click Compile buttonto compile the code, click upload to upload the code to the board. (or directly, skip Compile).
4) Wait for a moment until the following information appears at the bottom of the window, which indicates it is uploaded successfully.
5) Remove the USB cable, switch on the power. Put the test card under the sensor module of the robot. Press the start button for more than 2 seconds to enter the debugging mode. You will see that in the OLED screen, there are five pillars simulating the signal intensity that the 5 sensors have collected. Now put the first sensor on the left in the black stripe. So the one showing 1 has the strongest signal. As shown in figure below:
5.2 Motor Testing
This experiment is to test whether the motor wiring is right or not. There can be 4 situations: the wiring of both motors is normal; both motors are wired inversely; the left one is normal but the right one is wired inversely; and the right one is good while the left one is wired inversely. We will introduce how to distinguish the cases then.
First, find MotorTest.ino under RollbotMicro\Arduino Code\MotorTest and upload to the RollbotMicro and observe the robot.
NOTE: Please remember Speed_Dir since it will be useful in the programs related to the motors later.
1) If the robot goes forward, it indicates all motors are wired normally. There is no need to modify the value of the variable Speed_Dirin the program since it’s 0 by default.
2) If the robot goes backward, it means that both motors are wired inversely. You need to change the variable value 0 of Speed_Dirinto 1 to run the program normally.
3) If the robot rotates clockwise (always towards its right side), it indicates the left motor is wired normally while the right one is done reversely. You need to change the value 0 of Speed_Dir into 2.
4) If the robot spins anti-clockwise (always towards its left side), it indicates the right motor is wired normally while the left one is reverse. Change the value 0 of Speed_Dir to 3.
5.3 Line Following
This experiment is to let the robot goes forward along the black line. OLED displays the signal strength that 1, 5 sensor received. When the robot turns left, the yellow LED on the left lights. The yellow LED on the right lights when the robot turns right. No LED lights when the robot goes straight.
5.3.1 Magic Forest
1) Open RollbotMicroFollower1.ino under Rollbot\Arduino Code\Rollbot\Red Rollbot\ RollbotFollower1
Note: You need to modify the value of Speed_Dir according to the test in 5.2. It’s 0 by default. Then upload theRollbotMicroFollower1.ino to the RollbotMicro.
2) Take out the map and put it on a smooth surface like a table. Turn on the robot and place it with the middle detector over the black line on the map. Press the start button for more than 2 seconds. The robot will test the reference value of the black line automatically. Just wait patiently till it backs to the initial position after swaying a bit. This process is to test the sampling value of the black line. Then the robot will move along the line.
3) You will see the robot goes following the black line on the map. When the robot swings to the left relatively from the black line, the robot will turn towards the right to correct its direction and the LED on the left will keep blinking until it’s back on track; when the middle detector is right over the middle of the black line, the robot goes forward straightly; when it deviates to the right, it will turn left to correct and the LED on the right will blink.
4) If you have mastered the line-following program, you can try modifying the PD parameters to learn more the principle of line-following. After test, the debugging process is as follows: Set the PD to 0 and increase P slowly. When the robot starts wiggling side to side, increase the D value slowly to make the motion of the robot flat. So the PD adjustment is done successfully.
5.3.2 DIY Map
On a blank paper, you can draw a map you like according to instructions on the guide card. Three patterns are provided and you can also design by yourself. Then use the black tape to paste the map you designed on a flat floor or draw with the black Marker pen.
1) Open RollbotMicroFollower2.inounder Rollbot\Arduino Code\Rollbot\Red Rollbot\ RollbotMicroFollower2.
Note: You need to modify the value Speed_Dir according to the test in 5.2. It’s 0 by default. Thenupload the RollbotFollower2.inoto the RollbotMicro.
2) Put the completed map on a smooth surface like a table. Turn on the robot and place it with the middle detector over the black line on the map. Press the start button for more than 2 seconds. The robot will test the reference value of the black line automatically. Just wait patiently till it backs to the initial position after swaying a bit. This process is to test the sampling value of the black line. Then the robot will move along the line.
You can try more possibilities such as using a white chalk to draw maps on a dark smooth surface like the floor, set a gift at the end, and then wait for the RollbotMicro to discover the mysteries. The program for using chalk to draw the map is not provided in our data package. You can try to change the SignalValue into Sensor.Read_WhiteFlag() to explore.