Your shopping cart is empty!
Building Line Following Robot Using Maker Pi Pico, Maker Drive and Maker Line
- Bhavithiran Palani
- 17 Mar 2021
- 2739
OVERVIEW
Raspberry Pi Pico is the 1st Microcontroller Development Board from Raspberry Pi Foundation. It is also based on the 1st Microcontroller IC/Silicon - RP2040, designed and produced by Engineers from the Raspberry Pi team too.
Maker Pi Pico is Raspberry Pi Pico's extension board developed by Cytron Technologies. Maker Pi Pico gives you access to all Raspberry Pi Pico's pins on two 20 ways pin headers, with clear labels. Each GPIO is coupled with an LED indicator for convenient code testing and troubleshooting. The bottom layer of this board even comes with a comprehensive pinout diagram showing the function of each pin.
Maker Drive is a easy and beginner-friendly motor driver. Maker Drive is designed for simplicity and with the beginner in mind. Maker Drive is designed to be compact, roughly the size of a passport photo. Maker Drive has 4 Test Buttons (2 for each channel), 4 Indicator LEDs (2 for each channel).
Maker line is a easy and beginner-friendly line sensor. Maker Line also supports dual outputs: 5 x digital outputs for the state of each sensor independently which is similar to conventional IR sensor, but you get the benefit of easy calibration; One analog output where its voltage represents the line position. Analog output also offers higher resolution compared to individual digital outputs.
HARDWARE SETUP
Parts
- Maker Pi Pico x1
- Maker Drive x1
- Maker Line x1
- SR04P Ultrasonic Ranging Module x1
- Bracket for Ultrasonic HC-SR04 x1
- Aluminum 2WD TT Robot/Motor Chassis - Purple x1
- 4xAA Battery Holder C/W Cover x1
- GP 4 x AA Supercell Battery x1
- USB Micro B Cable x1
- M3 PCB Stand (screw & nut)15mm x4
- PCB Stand (screw & screw)10mm x4
- PCB Stand (screw & nut)5mm x4
- PCB Stand (screw & nut)10mm x2
- Grove 4 Pin Buckled to Female Cable x4
- Female to Female Jumper Wire x1
Wiring & Assembly
Solder the wires to the motors.
Mount motors to robot chassis.
Pass the wires through the chasis hole as shown below.
Tighten a 5mm PCB Stand on the chasis with the screw to mount Maker Drive.
Tighten a 5mm PCB Stand to Maker Drive.
Mount Maker Drive on the chasis. Only one PCB Stand is screwed to chasis.
Connect the wires to Maker Drive and mount the wheel to the motors.
Tighten a screw on the chasis as shown below to mount Maker Pi Pico later.
Stick a double-sided tape on the chasis and place battery holder (with battery) on it.
Connect the battery wires to Maker Drive and check the motors are running correctly.
Turn on the switch on battery holder and press button M1A & M2A on Maker Drive, the motors should be moving forward. Swap the wires if the motors are moving in wrong directions.
Place 15mm and 10mm PCB Stand together (or use 25mm PCB Stand) and tighten it to chasis.
Screw Maker Pi Pico with the PCB Stand.
Add PCB Stand to the remaining 3 sides of the Maker Pi Pico.
Connect the wires as shown below to power up Maker Pi Pico.
Connect wires from Maker Pi Pico to Maker Drive.
Tighten two 5mm PCB Stand at the bottom of chasis.
Install Maker Line with 10mm PCB Stand.
Connect wires from Maker Pi Pico to Maker Line.
Install ultrasonic sensor into the ultrasonic bracket.
Install ultrasonic sensor with bracket into the chasis.
Connect wires from Maker Pi Pico to ultrasonic sensor.
SOFTWARE SETUP
Installing MicroPython
Step 1: Hold down the ‘BOOTSEL’ button on the top of your Pico; then, while still holding it down connect a micro USB cable into the micro USB port on your Pico and computer. Count to three, then let go of the ‘BOOTSEL’ button.
Step 2: Pico appear as a removable drive, as though you’d connected a USB flash drive or external hard drive. You’ll see two files on your Pico - INDEX.HTM and INFO_UF2.TXT. Point the mouse cursor at the first file - INDEX.HTM and double-click it to open it in your browser.
Step 3: When the browser opens, click on the MicroPython tab to load the MicroPython-specific section of the page. Click on the ‘Download UF2 file’ button to download the MicroPython firmware.
Step 4: Copy the downloaded file to Pico’s removable storage drive.
Step 5: After a few seconds you’ll see your Pico disappear from File Manager.
Installing Thonny
Step 1: Open your web browser, visit thonny.org, and click the download link at the top of the page to download the Thonny installer.
Step 2: Open the Thonny software, with your Pico connected to your computer, click on the word ‘Python’ followed by a version number at the bottom-right of the Thonny window. In the list that appears, look for MicroPython (Raspberry Pi Pico) and click on it. If you can’t see it in the list, double-check that your Pico is properly plugged in to the micro USB cable and that the micro USB cable is properly plugged in to your computer.
CODING
Move Around
In this part, we will be learning on how to code the robot to move forward, reverse, turn left and turn right.
Add Library
Step 1: Download the library file (motor_driver.py) from here
Step 2: Launch Thonny application and open the library file
Step 3: Save the library file into the Raspberry Pi Pico
Step 4: Save the library with the same name you downloaded with (motor_driver.py) Must add .py at the back
Step 5: Click OK and the library is added to your Pi Pico
Get the library documentation here
Move Forward
Step 1: Open a new empty file.
Step 2: Copy & paste these code into your Thonny IDE.
Step 3: Save the file in Raspberry Pi Pico.
Step 3: Save the file as 'main.py' and click OK. Must add .py at the back.
Turn on the robot by using the switch at battery holder. The robot will move forward.
Move Backward
Follow the steps from "Move Forward" and add the code below.
Turn Left
Follow the steps from "Move Forward" and add the code below.
Turn Right
Follow the steps from "Move Forward" and add the code below.
Brake
Follow the steps from "Move Forward" and add the code below.
Example codes to drive the motors are here
Detect Object
In this part, we will be learning on how to code the robot to read ultrasonic sensor.
Follow the steps from "Move Forward" and add the code below.
This program will print ultrasonic distance in the unit of cm on the Thonny shell.
Example code to read ultrasonic is here
Line Following
In this part, we will be learning on how to code the robot to read line sensor and follow the line.
Follow the steps from "Move Forward" and add the code below.
This program will print line sensor analog value on the Thonny shell.
Follow the steps from "Move Forward" and add the code below.
This line follow example is the combination of the three program above .