yahboom
HomeTutorialsProduct
Solution
Blog
Online Store
About Us
EN/中文
Store
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

3.8 Servo control

3.8 Servo control

1. Learning objectives

  1. Learn the servo interface and PWM servo of the Raspberry Pi Pico 2/Pico mainboard and the car expansion board to conduct experiments.
  2. Understand the use of PWM servos.

2. Hardware use

This course uses the servo interface and PWM servo of the Pico 2/Pico mainboard and the car expansion board. When connecting the PWM servo, pay attention to the corresponding color of the connecting wire and the color of the pin header.

image-20220302120101167

The basic control principle of the PWM servo is to use the PWM signal to generate a signal with a period of 20ms and a duty cycle of 0.5~2.5ms, thereby controlling the servo angle.

3. Program Analysis

Code path: Code -> 1.Basic course -> 8. Servo control.py

​x
from pico_car import pico_car
Servo = pico_car()
​
#180 servo S1 angle 0
#the parameters are (steering gear number, steering gear angle)
Servo.servo180(1,0)
#270 servo
Servo.servo270(2,90)
#360 servo
Servo.servo360(3,360)

from pico_car import pico_car

Use pico_car of pico_car, which encapsulates the servo driver library.

Servo = pico_car()

Initialize the servo.

Servo.servo180(1,0)

Set the angle of 180-degree PWM servo S1 to 0 degrees.

Servo.servo270(2,90)

Set the angle of 270-degree PWM servo S2 to 90 degrees.

Servo.servo360(3,360)

Set the angle of 360-degree PWM servo S3 to 360 degrees.

4. Experimental Phenomenon

After the program is downloaded, we can see that the 180-degree servo, 270-degree servo, and 360-degree servo inserted in S1-S3 are at the positions of 0 degrees, 90 degrees, and 360 degrees respectively.

Battery power display
Light sensor

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/中文