4. Test the Modules

This chapter is suitable for usability testing of the modules before assembly; or for final commissioning and maintenance of the Pico-4wd after assembly has been completed.

Power up the Pico RDP

In order to make the module work, you need to power up the Pico RDP and turn the power switch to ON.


Test the Motors

  1. Connect the 4 motors according to the diagram below.

  2. Select Correct Interpreter

    Plug the Pico into your computer with a micro USB cable and select the “MicroPython (Raspberry Pi Pico).COMXX” interpreter in the bottom right corner.

  3. Go to the pico_4wd_car_main/tests path and double click on test_motor.py to open it.

  4. Click the Run current script button or just press F5 to run it.


Now, you can see the four motors work in a regular pattern. If you complete the assembly, this code will make the Pico-4wd perform five movements: forward, backward, left, right and stop.

Test the Ultrasonic Module

  1. Connect the ultrasonic module as shown below.

  2. Run the test_sonar.py file under the path pico_4wd_car_main/tests.


After running the code, the distance of ultrasonic detection will be displayed in the Shell. If the distance changes when your hand is in front of the ultrasonic module, the module is working properly.

Test the RGB Boards

  1. As shown below, connect the 3 RGB boards.

  2. Run the test_light.py file in pico_4wd_car_main/tests.


After the code is run, the 24 LEDs (all on the 3 RGB boards) to emit red, green, blue and white light in turn.

Test the Grayscale Sensor Module

  1. Diagrammatically connect the Grayscale Sensor Module.

  2. Run the test_grayscale.py file in pico_4wd_car_main/tests.


    Upon running, you will see that the values in the Shell change when you place the grayscale module at a height of about 1cm above the different surfaces, indicating that it is working properly.

    In general, the value for white surfaces > the value for black surfaces > the value for overhanging (grayscale module 10cm above the ground).

  3. Because light intensities differ in different environments, the factory-set contrast may not be suitable for your current environment, which means the grayscale module cannot identify white and black lines well, so it needs to be calibrated.

    • Tape a small piece of black electrical tape to the ground or table.

    • Hold the grayscale module 1 cm above the table (this is about the same height as after assembly, so you can use it directly after calibration).

    • Keep test_grayscale.py running, then use a screwdriver to adjust the potentiometer on the grayscale module until the values printed on the Shell are relatively far apart. Based on the actual situation, your values should differ from mine.


Test the Speed Module

  1. Follow the diagram below to connect the Speed Module.

  2. Run the test_speed.py file in pico_4wd_car_main/tests.


    The Thonny IDE contains a line graph tool, please open it by clicking View > Plotter in the navigation bar to help you see how the printed values are changing.


After the code runs, when you back and forth put the jammed paper into the U-shaped slot on the speed module/take it out. The Shell in Thonny IDE will print the current speed.

If you have already mounted it, this code will make the Pico-4wd move forward at variable speed and print out the motor power (as a percentage) and the travel speed (cm/s). To use it you should hover the car so that the motor rotation is not obstructed.

Test the Servo

  1. Connect the servo according to the following diagram.

  2. Run the test_servo.py file in pico_4wd_car_main/tests.


Insert a rocker arm first to observe the rotation of the servo. After clicking on the Run button, the servo will rotate left and right once and then stop at 0°.


For the next chapter, 5. Assemble the Car, the servo must be held at 0°, so after this code run, do not turn the servo shaft until the car is complete.

In the event that you accidentally turn the servo shaft, remove the rocker arm, run this code again, and then reassemble the servo.