Test for Servos and Ultrasonic Module

Share for us

Before assembling, you need to test the servos and the ultrasonic module according to the following steps.

Servo Test

Test the servos first, insert the SunFounder Nano board into the servo expansion board. Pay attention the USB port should be at the same side with the black power socket.

Connect the Nano board to computer with a USB cable, you can see a notification in system tray.

Open Arduino IDE, click File -> Examples -> Servo -> Sweep to open Sweep.ino.

In the code, the servo is set to be connected to pin 9 of the servo control board.

Prepare a servo and a 1-arm rocker arm, then mount the rocker arm onto the servo.

Connect the servo to pin 9. Pay attention to the wires, the yellow one connects to S, red one to V, and the brown one to G.

Select the right board.

And port of the Nano board in IDE. Then upload the sketch.

You will see the rocker on rotating within 0-180 degrees which indicates the servo can work. 

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.

Open Arduino IDE, and click File -> Examples -> Newping -> NewPingExample to open NewPingExample.ino

And connect the pin TRIG to pin 12 of the servo control board. ECHO to pin 11VCC to V and GND to G.

Upload the program to the Nano board, open the serial monitor. 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.