Waveshare AlphaBot 2 User manual

AlphaBot 2 User Manual
1
share awesome hardware
AlphaBot 2
User Manual
August 2017
V1.3

AlphaBot 2 User Manual
2
share awesome hardware
To the Reader
Selection Guide
Note: Accessories may be different in different product package. This manual describes all the
compatible accessories but perhaps the product you bought doesn’t contain some of them. The
figure below shows most the compatible accessories:
Package Contents
Products
Item
Description
AlphaBot2-
Ar Acc
Pack
AlphaBot2
-Ar
AlphaBot2-
Pi Acc Pack
AlphaBot2
-Pi
AlphaBot2-
PiZero Acc
Pack
AlphaBot2-Base
Motor driver, integrates sensors for
obstacle avoiding, line tracking
√
√
√
√
√
AlphaBot2-Ar
Adapter board, for connecting
Arduino
√
√
AlphaBot2-Pi
Adapter board, for connecting RPi3 B
√
√
AlphaBot2-PiZero
Adapter board, for connecting RPi
Zero W
√
RPi3 B
Raspberry Pi 3 Model B
√
UNO PLUS
Enhanced Arduino compatible board
√
Dual-mode Bluetooth
Dual-mode Bluetooth module
√
Ultrasonic sensor
Ultrasonic obstacle avoiding, ranging
√
√
√
IR remote controller
remotely control the robot
√
√
√
√
√
RPi Camera (B)
Raspberry Pi camera, adjustable focus
√
√
√
SG90
Servo, working with the pan head,
controlling the rotation of the camera
√
√
√
Micro SD Card 16GB
16GB Miro SD Card, class 10
√
√
√
5V 2.5A Power
Adapter
RPi3 B requires 2.5A or above power
supply
√
√
√
Note:
AlphaBot2-Ar Acc Pack requires an Arduino compatible controller, if you don't have one in hand,
please consider the all-in-one kits: AlphaBot2-Ar.
AlphaBot2-Pi Acc Pack requires the controller Raspberry Pi, if you don't have one in hand, please
consider the all-in-one kit: AlphaBot2-Pi.
AlphaBot2-PiZero Acc Pack requires the controller Raspberry Pi Zero/Zero W, which should be
purchased separately.
Due to the structure design, ultrasonic sensor module can NOT be used with the AlphaBot2-Pi kit.

AlphaBot 2 User Manual
3
share awesome hardware
Recommendation
Reading this document can be a challenge for a freshman. We advise that the
reader need to have some knowledge of the programming in Raspberry Pi Python
or Arduino, which can be helpful for understanding the programming
fundamentals. Due to space constraint, only a few of the programming
fundamentals can be explored here. If you want to have a thorough understand of
them, please check the source code. Here, we will describe more about the practical
experience of smart robot development.
Raspberry Pi tutorial:
http://www.waveshare.com/wiki/Raspberry_Pi_Tutorial_Series
Due to the electrical characteristic limitation, user should be more careful to use
this product in a safe and correct matter, to prevent the Raspberry Pi board or
Arduino board from irreversible damage by the smart robot chassis. For your first
time in using this product, please follow the steps described in the document.
Get details
Waveshare Wiki provides detailed data of AlphaBot2, including user manual,
schematic diagram, Demos, data sheet and the likes. Users can apply the product in
a safe and correct matter by reading them.
☺Resource Link: www.waveshare.com/wiki/AlphaBot2

AlphaBot 2 User Manual
4
share awesome hardware
Contents
AlphaBot 2 User Manual 1
To the Reader 2
Selection Guide 2
Recommendation 3
Get details 3
Contents 4
What’s on board? 5
Introduction 5
AlphaBot2-Base 6
AlphaBot2-Ar 7
AlphaBot2-Pi 8
AlphaBot2-PiZero 9
Quick start 10
Arduino examples 10
Raspberry Pi examples 24
FAQ 52
Safety Precautions 55
Notice Please reserve the following information for future use. 55

AlphaBot 2 User Manual
5
share awesome hardware
What’s on board?
Introduction
AlphaBot2 robot kits includes a chassis (AlphaBot2-Base chassis) and an adapter
board (one of the adapter boards AlphaBot2-Ar / AlphaBot2-Pi / AlphaBot2-PiZero).
The robot supports Arduino / Raspberry Pi 3 Model B / Raspberry Pi Zero W with
different adapter boards.
It features rich common robot functions including line tracking, obstacle avoiding,
Bluetooth / infrared / WiFi remote control, video monitoring, etc.
Thanks to the highly integrated modular design, it is fairly easy to assemble by a
snap, no soldering, no wiring. After a few minutes spent on hardware assembling,
you're almost there, our open source demo codes is ready to help you get started
fast.
Accessories may be different in different product package. This manual describes
all the compatible accessories but perhaps the product you bought doesn’t
contain some of them.

AlphaBot 2 User Manual
6
share awesome hardware
AlphaBot2-Base
1. AlphaBot2 control interface: for connecting sorts of controller adapter board
2. Ultrasonic module interface
3. Obstacle avoiding indicators
4. Omni-direction wheel
5. ST188: reflective infrared photoelectric sensor, for obstacle avoiding
6. ITR20001/T: reflective infrared photoelectric sensor, for line tracking
7. Potentiometer for adjusting obstacle avoiding range
8. TB6612FNG dual H-bridge motor driver
9. LM393 voltage comparator
10. N20 micro gear motor reduction rate 1:30, 6V/600RPM
11. Rubber wheels diameter 42mm, width 19mm
12. Power switch
13. Battery holder: supports 14500 batteries
14. WS2812B: true color RGB LEDs
15. Power indicator

AlphaBot 2 User Manual
7
share awesome hardware
AlphaBot2-Ar
1. AlphaBot2 control interface: for connecting AlphaBot2-Base
2. Arduino expansion header: for connecting Arduino shields
3. Arduino interface: for connecting Arduino compatible controller
4. Xbee connector: for connecting dual-mode Bluetooth module, remotely control
the robot via Bluetooth
5. IR receiver
6. PC8574: I/O expander, SPI interface
7. Arduino peripheral jumpers
8. TLC1543: 10-bit AD acquisition chip
9. Buzzer
10. 0.96inch OLED SSD1306 driver, 128x64 resolution
11. Joystick

AlphaBot 2 User Manual
8
share awesome hardware
AlphaBot2-Pi
1. AlphaBot2 control interface: for connecting AlphaBot2-Base
2. Raspberry Pi interface: for connecting Raspberry Pi 3 Model B
3. Servo interface
4. USB TO UART: easy for controlling the Pi via UART
5. LM2596: 5V voltage regulator
6. TLC1543: 10-bit AD acquisition chip, allows the Pi to use analog sensors
7. PCA9685: servo controller, make it more smoothly to rotate the pan head
8. CP2102: USB TO UART converter
9. Joystick
10. IR receiver
11. Buzzer

AlphaBot 2 User Manual
9
share awesome hardware
AlphaBot2-PiZero
1. AlphaBot2 control interface: for connecting AlphaBot2-Base
2. LM2596: 5V voltage regulator
3. Raspberry Pi interface: for connecting Raspberry Pi Zero/Zero W
4. IR receiver
5. Buzzer
6. FE1.1S: USB HUB chip
7. 12M crystal
8. USB TO UART: easy for controlling the Pi via UART
9. USB HUB interface: extends the USB port of Raspberry Pi Zero/Zero W
10. CP2102: USB TO UART converter
11. PCA9685: servo controller, make it more smoothly to rotate the pan head
12. TLC1543: 10-bit AD acquisition chip, allows the Pi to use analog sensors
13. Servo interface
14. USB indicators
15. USB ports: more USB capability

AlphaBot 2 User Manual
10
share awesome hardware
Quick start
We have provided the control programs for Arduino and Raspberry Pi, which can
implement many functions, such as tracking, obstacle avoidance, remote control,
video monitoring and so on.
You can get the example programs described in the following sections from the
website of Waveshare Wiki. To apply these examples to your application, you need
to copy the file libraries under the directory of Arduino into the folder libraries
under the installation directory of Arduino IDE. Then, restart the Ariduino IDE, and
click File-> Example to see if there is an option TRSensors. If yes, it means the
libraries are imported successfully. When using the Raspberry Pi, you should extract
the example programs and place them in the directory of /home/pi under the
operation system of Raspbian.
Arduino examples
Motor testing
Compile and download the program Run-Test. Normally, the smart robot moves
forward when the program runs and drives the motor to rotate. In case that the
direction of motion is wrong, you may need to modify the motor wring or change
the pin settings in your program. We recommend the latter one. If left wheels of the
robot run in a wrong direction, you should exchange the settings of AIN1 and AIN2.
For right wheels, exchange the settings of BIN1 and BIN2.
In the event that all the wheels run in a wrong direction, you should modify the

AlphaBot 2 User Manual
11
share awesome hardware
settings in the demos, like:
5-way Joystick
Compile and download the program Joystick. This Joystick has 5 control directions:
Up, Down, Left, Right and Center (Enter). Open the serial monitor, and set the baud
rate to 115200. Then, the monitor displays the current key press. When there is a
key pressed down, the buzzer sounds and the motor rotates in the direction
according to the key. If the wheel(s) runs in the wrong direction, you should modify
the settings of the corresponding pins.

AlphaBot 2 User Manual
12
share awesome hardware
Infrared remote control
Compile and download the program IR. You can control the smart robot by
pressing down the numeric keys on the infrared remote controller, in which, “2”is
for go forwards, “8”for go backwards, “4”for turn left, “6”for turn right, and
“5”for stop. Keys “-“and “+”can adjust the speed of the robot, and “EQ”
can restore the default setting of the speed.
The key encoding may change with different Infrared remote controller. You can
modify the program as required.
Infrared obstacle avoidance
Compile and download the program Infrared-Obstacle-Avoidance. When there is
no obstacle ahead of the robot, the green LEDs on the robot are off. When the
obstacle is detected, the green LEDs will light up. In case that the LEDs are always
off or always on, you can try to adjusted the potentiometers on the bottom of the
robot to make the LEDs work properly.

AlphaBot 2 User Manual
13
share awesome hardware
In this example, the robot goes straight when there is no obstacle, and turns right
when obstacle is detected.
Ultrasonic distance measurement
Compile and download the program Ultrasonic_Ranging. Open the serial monitor,
and set the baud rate to 115200. Then, the monitor displays the current measured
distance.
Ultrasonic obstacle avoidance
Compile and download the program Ultrasonic-Obstacle-Avoidance. In this
example, the robot goes straight when there is no obstacle, and turns right when
obstacle is detected. Since the ultrasonic can be reflected, if the obstacle is not in
the front of the robot, but is at an angle with the robot, the distance measured
between the robot and the obstacle may be inaccurate.

AlphaBot 2 User Manual
14
share awesome hardware
Ultrasonic infrared obstacle avoidance
Compile and download the program Ultrasonic-Infrared-Obstacle-Avoidance. In
this example, the robot goes straight when there is no obstacle, and turns right
when obstacle is detected.
Tracker sensor testing
Import the library TRSensors to the file libraries under the installation directory of
Arduino IDE. Then, click File -> Example -> TRSensors ->TRSensorExample to open
the project. Compile and download the program to the development board
Arduino.
The tracker sensor can detect the black line in the background color of white. You
can choose a black adhesive tape with 15cm width, and paste it to a white KT board
to create the smart robot tracking line scenario. The dark background color will
reduce the capability of the smart robot on the tracking line.
Open the serial monitor, and set the baud rate to 115200. When the monitor
displays the characters “TRSensor example”, you should hold the robot in the
middle of the black line and close to the ground, then swing the robot from side to
side. Then, the smart robot goes into the calibration mode, identifying the Max.
and the Min. threshed of each sensor. Calibration can have a direct influence to the
tracking line capability of the robot.
After the calibration, the monitor shows the Max. and the Min. threshed of each

AlphaBot 2 User Manual
15
share awesome hardware
sensor. And then, the measured values of sensors are displayed as well. The larger
value means the deeper color. The last column of values indicate the position of the
black line, in which “2000” means the black line is in the middle of the robot,
“0” means the black line is on the leftmost side of the robot, and “4000” means
the black line is on the rightmost side of the robot.
When this program runs well, the line tracking sensor works properly. Or else, the
sensor cannot perform line tracking.
Infrared line tracking
Compile and download the program Infrared-Line-Tracking. Turn on the power
adapter, and hold the robot in the middle of the black line and close to the ground,
then swing the robot from side to side. The smart robot goes into the calibration
mode, identifying the Max. and the Min. threshed of each sensor. Calibration can

AlphaBot 2 User Manual
16
share awesome hardware
have a direct influence to the tracking line capability of the robot. When the wheels
of the robot begin to move, you can release the robot and it will run along with the
black line.
RGB LEDs
Compile and download the program W2812. There are 4 RGBn LEDs (red, green,
blue and yellow, respectively) on the bottom of the robot.
To run this program, you should import the corresponding library to Arduino IDE.
OLED
Compile and download the program OLED. The example program demonstrates
the basic functions of character display and drawing operation, including drawing
line, cycle, rectangle box and the likes. To run this program, you should import the
corresponding library to Arduino IDE.
Comprehensive program
Compile and download the program Line-Tracking. Turned on the power adapter,
you can see the OLED display the characters “AlphaBot2”. Then, place the robot
on the black line and press down the key. Now, the smart robot goes into the
calibration mode, moving to left and then right. And the RGB LED is in green. When
the calibration finished, the RGB LED is in blue. OLED shows the information as the
figure below on the right, in which “**”indicates the current position of the black
line. When the smart robot moves to left or right, this symbol will be moved along.

AlphaBot 2 User Manual
17
share awesome hardware
Pressing down the key again, the smart robot runs along with the black line, and
the RGB LED shows different colors. When there is an obstacle detected, the smart
robot stops and the buzzer sounds. When the obstacle disappears, the smart robot
continue to run. If you take up the robot, it will stop as well. Then, place it on the
black line, it will run again.
Smart robot running mazes
Compile and download the program MazeSolver. Turned on the power adapter, you
can see the OLED display the characters “AlphaBot2”. Then, place the robot on
the black line and press down the key. Now, the smart robot goes into the
calibration mode, moving to left and then right. And the RGB LED is in green. When
the calibration finished, the RGB LED is in blue. OLED shows the information as the
figure below on the right, in which “**”indicates the current position of the black
line. When the smart robot moves to left or right, this symbol will be moved along.
If the smart robot comes across the right angle, it will take a turn and look for the
end automatically. The smart robot stops when it arrives the end. Now, put the
smart robot to the start again, and press down the key, you will find that the smart

AlphaBot 2 User Manual
18
share awesome hardware
robot runs to the end along with the shortest route.
Here are some requirements in making the maze: the corner should be a right angle,
and the maze should not has any loop.
About the program: when the smart robot detects any corner, it will slow down and
detects if there is a corner once again. As the difference at motor and operation
voltage in used, the smart robot may be unable to identify the corner. In this case,
you can modify the speed setting and delay time in the program. Further, when the
smart robot has to turn a corner, it need to increase delay time to judge the degree
of the angle. Therefore, if there is any problem in turning a corner, you can modify
the speed setting and delay time in the program as well.

AlphaBot 2 User Manual
19
share awesome hardware

AlphaBot 2 User Manual
20
share awesome hardware
Bluetooth control smart robot
Compile and download the program Bluetooth. You should remove the Bluetooth
module from the smart robot before downloading, or else the program cannot be
loaded. When finished, you should insert the Bluetooth module to the smart robot
again.
Then, scan the QR code below with your mobile phone, and download the relative
APP according to your mobile phone OS. For iOS, Bluetooth BLE is applied to
Table of contents
Other Waveshare Robotics manuals