SunFounder PiCar-S User manual

Preface
About SunFounder
SunFounder is a technology company focused on Raspberry Pi and Arduino open
source community development. Committed to the promotion of open source culture,
we strive to bring the fun of electronics making to people all around the world and
enable everyone to be a maker. Our products include learning kits, development
boards, robots, sensor modules and development tools. In addition to high quality
products, SunFounder also offers video tutorials to help your own project. If you have
interest in open source or making something cool, welcome to join us! Visit
www.sunfounder.com for more!
About the PiCar-S
The PiCar-S is a cool smart car that can work with Raspberry Pi 3 model B, 3 model B+,
and 4 model B. Equipped with three sensor modules including ultrasonic obstacle
avoidance, light follower, and line follower, you can better learn the programming on
how to control the car.
In this manual, we will show you how to build the PiCar-S via description, illustrations
of physical components, in both hardware and software respects. You will enjoy
learning how all this work. You may visit our website www.sunfounder.com to
download the related code and view the user manual on LEARN -> Get Tutorials and
watch related videos under VIDEO, or clone the code on our page of github.com at
https://github.com/sunfounder/SunFounder_PiCar-S
You are welcome to pull requests and issue posts on our page on Github.
Free Support
If you have any TECHNICAL questions, add a topic under FORUM section on our
website and we'll reply as soon as possible.
For NON-TECH questions like order and shipment issues, please send an email
to service@sunfounder.com. You're also welcomed to share your projects on
FORUM.

Contents
Components List.......................................................................................................................... 1
Structure Plates........................................................................................................................ 1
SunFounder SF006C Servo x 1............................................................................................ 2
Mechanical Fasteners............................................................................................................. 3
Wires........................................................................................................................................... 4
PCB.............................................................................................................................................. 4
Other Components................................................................................................................. 5
Tools............................................................................................................................................ 6
Introduction...................................................................................................................................7
Building the Car............................................................................................................................8
Front Half Chassis....................................................................................................................8
Front Wheels.............................................................................................................................8
Steering Part...........................................................................................................................10
Upper Plate............................................................................................................................. 11
Battery Holder....................................................................................................................... 12
Rear Wheels (Screws)...........................................................................................................13
PCB Assembly........................................................................................................................ 14
Rear Wheels (Driving).......................................................................................................... 15
Circuits Building......................................................................................................................... 17
Connect the Power............................................................................................................... 17
Connect the Modules.......................................................................................................... 18
Connect the Servo................................................................................................................ 19

Connect the Motor............................................................................................................... 20
Get Started with Raspberry Pi................................................................................................22
If You Have A Screen............................................................................................................23
- Required Components..............................................................................................23
- Procedures................................................................................................................... 23
If You Have No Screen......................................................................................................... 30
- Burn System.................................................................................................................30
- Connect the Raspberry Pi to the Internet........................................................... 31
- Start SSH.......................................................................................................................32
- Get the IP Address..................................................................................................... 32
- Use the SSH Remote Control..................................................................................33
Servo Configuration..................................................................................................................37
Get Source Code................................................................................................................... 37
Go to the Code Directory................................................................................................... 37
Install the Environment via Script.....................................................................................38
Set the Servo to 90 Degrees.............................................................................................. 38
Build the Rest of the Car..................................................................................................... 40
Calibration................................................................................................................................... 43
Calibrate the Servo............................................................................................................... 43
Calibrate the Motors............................................................................................................ 44
Arming the Car!..........................................................................................................................46
Obstacle Avoidance..............................................................................................................47
- How it Works...............................................................................................................47
- Procedures................................................................................................................... 47
- Code Explanation for ultra_sonic_avoid.py......................................................... 49

Light Following...................................................................................................................... 52
- How It Works...............................................................................................................52
- Procedures................................................................................................................... 52
- Code Explanation for light_follower.py................................................................55
Line Following........................................................................................................................59
- How it works................................................................................................................59
- Procedures................................................................................................................... 59
- Code Explanation of line_follower.py................................................................... 63
Combination............................................................................................................................... 68
- How it works................................................................................................................68
Appendix 1: Installing Manually............................................................................................ 70
Appendix 2: Modules................................................................................................................71
Robot HATS............................................................................................................................ 71
PCA9865.................................................................................................................................. 72
Motor Driver Module...........................................................................................................73
Line Follower Module.......................................................................................................... 74
Light Follower Module........................................................................................................ 75
Ultrasonic Obstacle Avoidance Module......................................................................... 76
SunFounder SF006C Servo................................................................................................. 77
DC Gear Motor...................................................................................................................... 78
Copyright Notice...................................................................................................................78

1
Components List
Structure Plates
1. Upper Plate x 1
2. Front Half Chassis x 1
3. Hex Front Wheel Fixing Plate x 6
4. Ultrasonic Support x 1
5. Bearing Shield x 6
6. Steering Linkage x 1
7. Steering Connector x 2
8. Ultrasonic Connector x 1
9. Back Half Chassis x 1
10. Sensor Connector x 1

2
SunFounder SF006C Servo x 1
1. Servo x 1
2. 1-arm Rocker Arm x 1
3. arm Rocker Arm x 1
4. 4-arm Rocker Arm x 1
5. Rocker Arm Fixing Screw x 1
6. Rocker Arm Screw

3
Mechanical Fasteners
Name Component Qty.
M2x8 Screw 2
M2.5x6 Screw 4
M2.5x12 Screw 8
M3x8 Screw 8
M3x8 Countersunk Screw 2
M3x10 Screw 9
M3x25 Screw 4
M4x25 Screw 2
M2 Nut 2
M2.5 Nut 12
M3 Nut 23
M4 Self-locking Nut 2
M2.5x8 Copper Standoff 8
M3x25 Copper Standoff 8
4x11x4 F694ZZ Flange
Bearing 2

4
Wires
100mm 5-Pin
Jumper Wire 1
50mm 4-Pin
Jumper Wire 1
50mm 2-Pin
Jumper Wire 1
100mm 2-Pin
Jumper Wire 1
200mm 5-Pin
Jumper Wire 1
200mm 4-Pin
Jumper Wire 1
200mm 3-Pin
Jumper Wire 1
PCB
Robot HATS 1

5
PCA9685 PWM
Driver 1
Motor Driver
Module 1
5-CH Line
Follower
Module
1
Ultrasonic
Obstacle
Avoidance
Module
1
Light Follower
Module 1
Other Components
2x18650 Battery
Holder 1

6
DC Gear Motor 2
Rear Wheel 2
Front Wheel 2
Ribbon (30cm) 1
Tools
Cross
Screwdriver 1
Cross Socket
Wrench 1
M2.5/M4 Small
Wrench 1
M2/M3 Small
Wrench 1

7
Introduction
The is a SMART SENSOR car robot based on Raspberry Pi, which comes with
three sensor modules, including the light follower, line follower and ultrasonic
obstacle avoidance. With these modules, this smart car is capable of some simple
automatic actions. Thus, you can learn some basics of programming in Python to
control the car with these sensors. Let’s start with building this smart car!

8
Building the Car
Extremely excited when opening the box and checking so many components? Keep
your patience and take it easy. Please note that some details in the following steps
need CAREFUL observation. You should double-check your work based on the figures
in the manual after finishing each step. Don’t worry! Kindly reminders will be given in
some particular steps. Just follow the tutorial step by step. Okay, with no further ado,
now let’s start!
Front Half Chassis
Assemble the Front Half Chassis with four M3x25 copper standoffs and four M3
nuts as shown below:
Front Wheels
Note: Please pay attention to the direction of Steering Connector before assembling.
Insert an M4x25 screw through a Flange Bearing (pay attention to the direction –
the flange near the cap of the screw), a Steering Connector, 3 Bearing Shields, 3 Hex
Front Wheel Fixing Plates, and a front wheel, into an M4 Self-locking Nut (note the
direction) as shown below:
Flange

9
You can use the Cross Socket Wrench to secure the M4 Self-locking Nut, then use the
screwdriver to tighten the M4x25 screw.
Note:
The Self-locking Nut should be screwed tight enough. It would be better to tighten the
screw until the wheel and Steering Connector cannot move first, then loosen the screw
a little, so that the Steering Plate can just move. Thus, the wheel can turn flexibly when
the connection would not be too loose.
Assemble the other front wheel in the same way, but bear in mind the Steering
Connector on the wheel should be symmetric with the previous one:
Now two front wheels have finished assembly.

10
Steering Part
Connect the Steering Linkage and the rocker arm with the Rocker Arm Screw (a
longer one in the servo package).
Note: Insert it into the first hole of the arm (as indicated by the arrow below) which is
the farthest from the gears. Since the screw is larger than the hole, you should try to
screw it hardly so as tight to the arm. Don't worry of the arm which is soft.
Note: Fasten them as tightly as possible, and then loosen the screw a little so the
Steering Linkage can move flexibly. Besides, the screw is quite sharp at the end, so be
careful to assemble in case of getting hurt.

11
Upper Plate
Mount the M2.5x8 copper standoffs and M2.5 nuts into the upper plate first. Pay
attention that the side the protruding prop should face up.

12
Battery Holder
Turn the Upper Plate upside down. Cut the ribbon into two halves. Thread them
through the holes on the plate. Pay attention to the direction and leave one end longer
out of the plate for each to remove the battery easily later.
Fasten the battery holder with two M3x8 countersunk screws and two M3 nuts: pay
attention to the direction of battery holder’s wire.

13
Rear Wheels (Screws)
Insert four M3x8 screws with four M3x25 copper standoffs:

14
PCB Assembly
1) Assemble the Raspberry Pi (TF Card inserted) with eight M2.5x8 copper standoffs,
then plug the Robot HATS onto it.
2) Fix the Robot HATS with four M2.5x6 screws.
3) Fix The PCA9685 PWM Driver, the Motor Driver with eight M2.5x12 screws and
M2.5 nuts into the down plate.
Motor Driver
PCA9685
PWM Driver
Robot HAT
Raspberry Pi

15
Rear Wheels (Driving)
Assemble the two motors to the Back Half Chassis with four M3x25 screws and M3
nuts.Pay attention to place the motors with wires inward, providing convenience for
connecting the circuit.
Assemble the rear wheels with 4 M3 nuts.
Place wires
inwards

16
Align the rear wheels with the motor shaft, and rotate to insert them gently.
Other manuals for PiCar-S
2
Table of contents
Other SunFounder Motorized Toy Car manuals