yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Pico Robot Car📖
0.Introduction
  • 0.1 Description of Pico Robot
  • 0.2 Interface Description
1.Assembly steps
  • Assembly video
2.Development environment construction
  • 2.1 Update firmware
  • 2.2 Build environment
  • 2.3 Download code Startup automatically
  • 2.4 Import library file
3.Basic course
  • 3.1 Control LED light
  • 3.2 Onboard temperature sensor
  • 3.3 Passive buzzer
  • 3.4 Breathing light
  • 3.5 Marquee light
  • 3.6 OLED display
  • 3.7 Battery power display
  • 3.8 Servo control
4.Advanced course
  • 4.1 Light sensor
  • 4.2 Sound sensor
  • 4.3 Tracking sensor
  • 4.4 Ultrasonic sensor
  • 4.5 IR control display
5.Robot course
  • 5.1 Car forward
  • 5.2 Car movement
  • 5.3 Singing dancing
  • 5.4 Car tracking
  • 5.5 Edge detection
  • 5.6 Ultrasonic avoiding
  • 5.7 Ultrasounic following
  • 5.8 Light follow
  • 5.9 Voice control car
  • 5.10 Infrared control
  • 5.11 Bluetooth control
6.Battery and charge
  • Battery and charge
Download
  • APP(iOS/Android)
  • Code
  • Instructions Manual
  • Appendix
Download ZIP

Welcome to Pico Robot Car repository

5.2 Car movement

5.2 Car movement

Note: Motor speed is affected by battery power. For this course, when the battery power is high (the power value is above 26000), if the battery power is not enough, we need to charge battery in time or modify the motor speed in the code.

1. Learning Objectives

In this course, we will learn how to drive motors in different directions on Pico robot.

2. About Hardware

We need use the motor on Pico robot.

Note: The effect of the following code is that the car advances, backward, turn left and turn right. Before running this code, please make sure the wheels are off the ground or table to avoid impact damage to the car.

image-20220302144157953

On the expansion board of the car, we integrate the motor drive circuit, and only need to use PWM to control the direction and speed of the motor. By adjusting the duty cycle of the PWM, the longer the high level time, the faster the motor speed. Inside the motor, the current is turned into a magnetic field through the coil, and the rotation of the motor is realized under the action of the magnet.

3. About code

Code path: Code -> 3.Robotics course -> 2.Car movement.py

​x
from pico_car import pico_car
import time

Motor = pico_car()
#Car forward,parameter(Left motor speed,Right motor speed),speed 0-255
Motor.Car_Run(255,255)
time.sleep(1)
#Car back
Motor.Car_Back(255,255)
time.sleep(1)
#left
Motor.Car_Run(0,255)
time.sleep(1)
#right
Motor.Car_Run(255,0)
time.sleep(1)
#Turn left
Motor.Car_Left(255,255)
time.sleep(1)
#Turn right
Motor.Car_Right(255,255)
time.sleep(1)
#Car stop
Motor.Car_Stop()

from pico_car import pico_car

Use pico_car of pico_car, which is our packaged motor driver library.

import time

The "time" library. This library handles everything time related, from measuring it to inserting delays into programs. The unit is seconds.

Motor = pico_car()

Initialize the motor drive.

Motor.Car_Run(255,255)

To control the car to move forward, the speed is set to 255, the parameters are (left motor speed, right motor speed), and the speed range is 0-255.

Motor.Car_Stop()

Control the car to stop.

Motor.Car_Back(255,255)

Control the car to back up.

Motor.Car_Run(0,255)

Control the car to turn left.

Motor.Car_Run(255,0)

Control the car to turn right.

Motor.Car_Left(255,255)

Control the car to turn left.

Motor.Car_Right(255,255)

Control the car to rotate right.

4. Experimental Phenomenon

After the code is downloaded, the car will move forward at the maximum speed for 1s, then backwards for 1s, turn left for 1s, turn right for 1s, rotate left for 1s, rotate right for 1s, and finally stop.

Car forward
Singing dancing

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文