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.
WIRING AND ASSEMBLYSolder the wires to the motors.
Mount motors to robot chassis.
Pass the wires through the chasis hole as shown below.
Mount the wheel to the motors.
Screw PCB stand according to the picture
Stick a double-sided tape on the chasis and place battery holder (with battery) on it.
Screw Maker Pi RP2040 with the PCB stand.
Connect the battery and motor wires to Maker Pi RP2040 and check the motors are running correctly.
.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 and connect wires.
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 Maker Pi RP2040 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 CircuitPython (generic) and click on it. If you can’t see it in the list, double-check that your Maker Pi RP2040 is properly plugged in to the micro USB cable and that the micro USB cable is properly plugged in to your computer.
Move Forward
Step 1: Open a new empty file.
Step 2: Copy & paste these code into your Thonny IDE.
import board
import digitalio
import simpleio
import time
import pwmio
from adafruit_motor import servo, motor
# Initialize DC motors
m1a = pwmio.PWMOut(board.GP8, frequency=10000)
m1b = pwmio.PWMOut(board.GP9, frequency=10000)
motor1 = motor.DCMotor(m1a, m1b)
m2a = pwmio.PWMOut(board.GP10, frequency=10000)
m2b = pwmio.PWMOut(board.GP11, frequency=10000)
motor2 = motor.DCMotor(m2a, m2b)
# Move motors at 50% speed
motor1.throttle = 0.5 # motor1.throttle = 1 or -1 for full speed
motor2.throttle = -0.5
Step 3: Save the file in Maker Pi RP2040.
Turn on the robot by using the switch at battery holder. The robot will move forward.
MoveBackward
Follow the steps from "Move Forward" and add the code below.
import board
import digitalio
import simpleio
import time
import pwmio
from adafruit_motor import servo, motor
# Initialize DC motors
m1a = pwmio.PWMOut(board.GP8, frequency=10000)
m1b = pwmio.PWMOut(board.GP9, frequency=10000)
motor1 = motor.DCMotor(m1a, m1b)
m2a = pwmio.PWMOut(board.GP10, frequency=10000)
m2b = pwmio.PWMOut(board.GP11, frequency=10000)
motor2 = motor.DCMotor(m2a, m2b)
# Move motors at 50% speed
motor1.throttle = -0.5 # motor1.throttle = 1 or -1 for full speed
motor2.throttle = 0.5
TurnLeft
Follow the steps from "Move Forward" and add the code below.
import board
import digitalio
import simpleio
import time
import pwmio
from adafruit_motor import servo, motor
# Initialize DC motors
m1a = pwmio.PWMOut(board.GP8, frequency=10000)
m1b = pwmio.PWMOut(board.GP9, frequency=10000)
motor1 = motor.DCMotor(m1a, m1b)
m2a = pwmio.PWMOut(board.GP10, frequency=10000)
m2b = pwmio.PWMOut(board.GP11, frequency=10000)
motor2 = motor.DCMotor(m2a, m2b)
# Move motors at 50% speed
motor1.throttle = -0.5 # motor1.throttle = 1 or -1 for full speed
motor2.throttle = -0.5
TurnRight
Follow the steps from "Move Forward" and add the code below.
import board
import digitalio
import simpleio
import time
import pwmio
from adafruit_motor import servo, motor
# Initialize DC motors
m1a = pwmio.PWMOut(board.GP8, frequency=10000)
m1b = pwmio.PWMOut(board.GP9, frequency=10000)
motor1 = motor.DCMotor(m1a, m1b)
m2a = pwmio.PWMOut(board.GP10, frequency=10000)
m2b = pwmio.PWMOut(board.GP11, frequency=10000)
motor2 = motor.DCMotor(m2a, m2b)
# Move motors at 50% speed
motor1.throttle = 0.5 # motor1.throttle = 1 or -1 for full speed
motor2.throttle = 0.5
Brake
Follow the steps from "Move Forward" and add the code below.
import board
import digitalio
import simpleio
import time
import pwmio
from adafruit_motor import servo, motor
# Initialize DC motors
m1a = pwmio.PWMOut(board.GP8, frequency=10000)
m1b = pwmio.PWMOut(board.GP9, frequency=10000)
motor1 = motor.DCMotor(m1a, m1b)
m2a = pwmio.PWMOut(board.GP10, frequency=10000)
m2b = pwmio.PWMOut(board.GP11, frequency=10000)
motor2 = motor.DCMotor(m2a, m2b)
# Brake
motor1.throttle = 0 # motor1.throttle = 1 or -1 for full speed
motor2.throttle = 0
DetectObject
Follow the steps from "Move Forward" and add the code below.
import time
import board
import adafruit_hcsr04
sonar = adafruit_hcsr04.HCSR04(trigger_pin=board.GP2, echo_pin=board.GP3)
while True:
print((sonar.distance,))
time.sleep(0.1)
This program will print ultrasonic distance in the unit of cm on the Thonny shell.
Line Following
Follow the steps from "Move Forward" and add the code below.
import board
import digitalio
import analogio
import simpleio
import time
import pwmio
from adafruit_motor import servo, motor
# Initialize DC motors
m1a = pwmio.PWMOut(board.GP8, frequency=10000)
m1b = pwmio.PWMOut(board.GP9, frequency=10000)
motor1 = motor.DCMotor(m1a, m1b)
m2a = pwmio.PWMOut(board.GP10, frequency=10000)
m2b = pwmio.PWMOut(board.GP11, frequency=10000)
motor2 = motor.DCMotor(m2a, m2b)
line = analogio.AnalogIn(board.GP26) # Set pin 26 as analog INPUT
sen_cal = digitalio.DigitalInOut(board.GP27)
sen_cal.direction = digitalio.Direction.OUTPUT
sen_cal.value = True
def read_line_sensor(): # read line sensor function
return (line.value)
while True:
line_value = read_line_sensor()
if line_value > 60000: # All line
motor1.throttle = 0.6
motor2.throttle = -0.6
elif line_value > 40000: # S5,S4+S5
motor1.throttle = 0.6
motor2.throttle = 0.4
elif line_value > 34000: # S4,S3+S4
motor1.throttle = 0.6
motor2.throttle = -0.5
elif line_value > 30000: # S3
motor1.throttle = 0.6
motor2.throttle = -0.6
elif line_value > 22000: # S2,S3,+S2
motor1.throttle = 0.5
motor2.throttle = -0.6
elif line_value > 10000: # S1,S2+S1
motor1.throttle = -0.4
motor2.throttle = -0.6
elif line_value > 200: # No line
motor1.throttle = 0.3
motor2.throttle = -0.3
Comments