Before assembling, you need to test the servos and the ultrasonic module according to the following steps.
i. Servo Test
- Physical Test
Please prepare four servos and four unilateral rocker arms and install the rocker arm on the servo. If you shake the rocker arm by hand, if the sound is inconsistent and the rotation is not smooth, the servo may be damaged. It is recommended that the following software tests be performed. If the servo does not work properly, we believe that the servo has been damaged.
2. Software Test
Insert SunFounder Nano board into the Servo Control Board. Note: The USB port should be at the same side with blue power supply terminal.
Connect the Nano board to computer with a USB cable, you can see a notification in system tray. Then open the program Test_robot.ino and go to line 21. In the code, four servos are connected to pin 9 to pin 12 of the expansion board.
Insert the battery to the battery cable.
And connect the battery cable to the expansion board.
Connect four servos to pin 9 to pin 12 of the expansion board.
Note: The yellow, red, and brown wires connect to Signal, VCC, and GND on the expansion board, respectively.
Select the right board to Nano board in IDE.
Then select the right port and upload the sketch.
After waiting for a few seconds, the download process is successful. The following window will prompt “Done uploading”.
Press the power button on the servo control board. You will see the rocker arm rotates within 0-180 degrees, indicating the servo can work. Then press the power button again to turn it off.
Keep the Test_robot.ino file open, and ii. Ultrasionic Test still needs to use this file in the next step.
ii. Ultrasonic Test
Connect the ultrasonic connecting cable to the ultrasonic module, it has an anti-reversing port. Here the 4 pins are marked with labels on the modules.
Go to line 10 and 11, you can see that TRIGGER_PIN is defined as 5 and ECHO_PIN is defined as 4.
And connect the pin TRIG to pin 4 of the servo control board. ECHO to pin 3, VCC to V and GND to G.
Go to Line 16, disable the SERVO and activate the ULTRASONIC.
Upload the program to the Nano board, open the serial monitor. Then press the power button on the servo control board. Set the baud rate as 115200, hold the ultrasonic module and make the two ultrasonic “eyes” facing an obstacle, move the robot back and forth, and observe the data shown on serial monitor. If the data changes with the robot’s moving, it proves the ultrasonic module is good. At last, turn it off, and unwire the battery.