Page 5
SunFounder pisloth Thanks for choosing our PiSloth. PiSloth is a Raspberry Pi Bionic robot with an aluminum alloy structure. It can talk, dance, and even express emotions, such as happiness and excitement. It has 22 different actions, such as: Stomp, Swing and MoonWalk, and you can customize the actions according to your needs.
CHAPTER COMPONENT LIST AND ASSEMBLY INSTRUCTIONS You need to check whether there are missing or damaged components according to the list first. If there are any problems, please contact us and we will solve them as soon as possible. Please follow the steps on the PDF to assemble. Note: 1.
Page 8
SunFounder pisloth Chapter 1. Component List and Assembly Instructions...
CHAPTER ABOUT ROBOT HAT Robot HAT is a multifunctional expansion board that allows Raspberry Pi to be quickly turned into a robot. An MCU is on board to extend the PWM output and ADC input for the Raspberry Pi, as well as a motor driver chip, Bluetooth module, I2S audio module and mono speaker.
Page 10
SunFounder pisloth Accepts 7-12V PH2.0 2pin power input with 2 power indicators. The board also has a user available LED and a button for you to quickly test some effects. Note: You can see more details in the Robot HAT Documentation.
Ezblock Studio to play with PiSloth. 3.1.1 Before Assembling PiSloth Before assembling the PiSloth, follow the instructions on how to install the Ezblock OS on an Micro SD card here: Download and Install Ezblock After burning the Ezblock system on the SD-card, the P11 port on the Robot HAT is set to calibrate the servo angle to a 0°...
Page 12
SunFounder pisloth Next, insert the servo cable into the P11 port as shown below: Turn on the Power Switch to the Robot HAT, and the servo arm should return to the 0° position. If the servo arm does not return to 0°, press the RST button to restart the Robot HAT.
Projects Here, we show you the projects of playing PiSloth on Ezblock Studio. If you are new to these, you can refer to the code images inside each project to program, and can learn the use of blocks according to TIPS.
Page 14
Forever block is, as the name suggests, a continuous loop that allows your program to change and respond. This block is used to make PiSloth do a specific action several steps at a speed (%), for example, let PiSloth go forward 1 step at 50% speed.
Page 15
After writing the code according to the following figure, click the download icon in the bottom right corner, you will see PiSloth move forward 3 steps, backward 4 steps, left 3 steps, right 5 steps, and finally stop. Since the whole code is placed inside the Forever block, PiSloth will repeat the above actions after stopping for a while.
SunFounder pisloth 3.3 Don’t Touch Me If you don’t meet PiSloth’s needs, it will get angry and stay away from your touch. TIPS You can directly use this block to read the distance to the obstacle right ahead. Note: When assembling, Trig and Echo are connected to D2 and D3 respectively, you also need to change them simultaneously when programming.
Page 17
SunFounder pisloth To achieve conditional judgment of “if” type, you need to use an if do block. When you need to implement multiple conditional judgments, you will have to change if do into if else do. This can be achieved by clicking on the setting icon.
Page 18
SunFounder pisloth EXAMPLE Chapter 3. Play with Ezblock...
EXAMPLE After the code runs, PiSloth will walk forward. If it detects that the distance of the obstacle ahead is less than 10cm, it will stop and sound a warning, then turn left for 7 steps and stop. If there is no obstacle in the direction after turning left or the obstacle distance is greater than 10, it will continue to move forward.
Page 20
SunFounder pisloth Chapter 3. Play with Ezblock...
SunFounder pisloth 3.5 Emotional PiSloth PiSloth is very emotional, sometimes happy, sometimes shy, sometimes confused. TIPS You may want to simplify the program with Functions, especially when you perform the same operation multiple times. Putting these operations into a newly declared function can greatly facilitate your use.
Page 22
SunFounder pisloth Confuse Happy Chapter 3. Play with Ezblock...
Page 23
SunFounder pisloth Fear 3.5. Emotional PiSloth...
Page 24
SunFounder pisloth Fall Call all custom functions in the Forever block. Chapter 3. Play with Ezblock...
SunFounder pisloth 3.6 Dance Now, PiSltoh will show you his newly learned dance. 3.6. Dance...
Page 26
PiSloth. TIPS In addition to having PiSloth play sound effects and speak, it can also play set background music, and the volume of the background music can be adjusted (0%-100%). Repeat block can help you execute the same code multiple times to reduce code size.
Page 27
SunFounder pisloth EXAMPLE The whole dance is divided into 2 parts, and PiSloth will finish these 2 parts with the music. If you don’t pause the code, it will repeat the dance. 3.6. Dance...
Page 28
SunFounder pisloth Chapter 3. Play with Ezblock...
SunFounder pisloth 3.7 Let’s Fight! Warrior! Here, PiSloth is a brave warrior, when it appears in front of the enemy, it will let out a roar and rush to the enemy. Note: You can download and print the PDF Cartoon Mask for your PiSloth.
Page 30
SunFounder pisloth TIPS You may want to simplify your program with Variable. For example, when you have multiple functions that need to read the obstacle distance, you don’t need to read the value for each function, just load the value into a variable and use it multiple times.
Page 31
After the code is run, PiSloth will continuously detect the distance of the obstacle, when the distance is between 5 and 40, PiSloth will make a roaring sound and rush forward; when the distance of the obstacle is less than 5, PiSloth will stop.
Page 32
SunFounder pisloth Chapter 3. Play with Ezblock...
SunFounder pisloth 3.8 Remote Control You can also use the widgets on Ezblock Studio to make PiSloth move. • How to Use the Remote Control Function? TIPS To use the remote control function, you need to enter the Remote Control page from the left side of main page, and then drag one D-pad and 4 buttons to the central area.
Page 34
SunFounder pisloth in it. • Button () get value: This block is used to read the value of the buttons, if the button is pressed, the value is 1, otherwise it is 0. • Button () is (press/release): This block and Button () get value = (0/1) have the same effect and can be used directly to determine whether a button is pressed or not.
In this project, we will learn how to customize PiSloth’s step. All we have to do is to use the buttons in the remote control page to make PiSloth complete the step shown in the figure below, and then get the angles of the 4 Servos at that time.
Page 37
SunFounder pisloth Step 2: Create 4 variables to store the angles of the 4 Servos. Then initialize the angle to 0. 3.9. Custom Step...
Page 38
SunFounder pisloth Step 3: Reads the values of the different buttons that are used to control the angles of the Servos. • button AB control the left-leg. • button CD control the left-foot. • button EF control the right-leg. • button GH control the right-foot.
Page 40
Step 5: Once the code is complete, click the download icon in the bottom right corner to download and run the code. Now we can click button CD and button GH (according to the actual code) to make PiSloth pose like this, you can also make it do other steps.
Page 41
SunFounder pisloth The complete code is as follows: 3.9. Custom Step...
3.10 Custom Action In the previous project, we were able to give PiSloth custom steps, so how do we combine these steps into actions? For example, have PiSloth make the step from the previous project and then return to the initial position.
Page 43
TIPS Create a variable up_down to store this action. You can use the create action block to make PiSloth do this action. These values represent the angles of the 4 Servos on the PiSloth. The range is (-90~90). 3.10. Custom Action...
Page 44
Here you can increase or decrease the number of items by dragging it. Fill in the angle obtained in the previous project and name this action up_down (drag it from Variables category). Use the do block to make PiSloth do this action once at 50% speed. EXAMPLE...
CHAPTER FOUR PLAY WITH PYTHON If you want to program in python, then you will need to learn some basic Python programming skills and basic knowledge of Raspberry Pi, please configure the Raspberry Pi first according to Quick Guide on Python.
Page 46
SunFounder pisloth Power Adapter To connect to a power socket, the Raspberry Pi has a micro USB port (the same found on many mobile phones). You will need a power supply which provides at least 2.5 amps. Micro SD Card Your Raspberry Pi needs an Micro SD card to store all its files and the Raspberry Pi OS.
Page 47
SunFounder pisloth Sound or Earphone The Raspberry Pi is equipped with an audio port about 3.5 mm that can be used when your screen has no built-in speakers or when there is no screen operation. 4.1.2 Installing the OS Required Components...
Page 48
SunFounder pisloth Note: 1) You will need to be connected to the internet the first time. 2) That will then stored future offline use(lastdownload.cache, C:/Users/yourname/AppData/Local/Raspberry Pi/Imager/cache). So the next time you open the software, it will have the display “Released: date, cached on your computer”.
Page 49
SunFounder pisloth Then scroll down to complete the wifi configuration and click SAVE. Note: wifi country should be set the two-letter ISO/IEC alpha2 code for the country in which you are using your Raspberry Pi, please refer to the following link: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_...
Page 50
SunFounder pisloth Step 7 Click the WRITE button. Chapter 4. Play with Python...
Page 51
SunFounder pisloth Step 8 If your SD card currently has any files on it, you may wish to back up these files first to prevent you from permanently losing them. If there is no file to be backed up, click Yes.
Page 52
SunFounder pisloth Step 9 After waiting for a period of time, the following window will appear to represent the completion of writing. Chapter 4. Play with Python...
Page 53
SunFounder pisloth 4.1.3 Set up Your Raspberry Pi If You Have a Screen If you have a screen, it will be easy for you to operate on the Raspberry Pi. Required Components Any Raspberry Pi 1 * Power Adapter 1 * Micro SD card...
Page 54
SunFounder pisloth If You Have No Screen If you don’t have a display, you can log in to the Raspberry Pi remotely, but before that, you need to get the IP of the Raspberry Pi. Get the IP Address After the Raspberry Pi is connected to WIFI, we need to get the IP address of it. There are many ways to know the IP address, and two of them are listed as follows.
Page 55
SunFounder pisloth Use the SSH Remote Control We can open the Bash Shell of Raspberry Pi by applying SSH. Bash is the standard default shell of Linux. The Shell itself is a program written in C that is the bridge linking the customers and Unix/Linux. Moreover, it can help to complete most of the work needed.
Page 56
SunFounder pisloth Step 4 Input the passcode and the default password is raspberry. Step 5 We now get the Raspberry Pi connected and are ready to go to the next step. Chapter 4. Play with Python...
Page 57
SunFounder pisloth Note: When you input the password, the characters do not display on window accordingly, which is normal. What you need is to input the correct password. For Windows Users If you’re a Windows user, you can use SSH with the application of some software. Here, we recommend PuTTY.
Page 58
SunFounder pisloth Step 3 Click Open. Note that when you first log in to the Raspberry Pi with the IP address, there prompts a security reminder. Just click Yes. Step 4 When the PuTTY window prompts “login as:”, type in “pi”(the user name of the RPi), and password: “raspberry”...
Page 59
SunFounder pisloth Step 5 Here, we get the Raspberry Pi connected and it is time to conduct the next steps. Note: If you are not satisfied with using the command window to control the Raspberry Pi, you can also use the remote desktop function, which can help us manage the files in the Raspberry Pi easily.
Page 60
SunFounder pisloth Then download the code and install pisloth library. /home/pi/ git clone -b v2.0 https://github.com/sunfounder/pisloth.git cd pisloth sudo python3 setup.py install This step will take a little time, so please be patient. Finally, you need to run the script i2samp.sh to install the components required by the i2s amplifier, otherwise the pislot will have no sound.
Page 61
SunFounder pisloth Type y and press Enter to continue running the script. Type y and press Enter to run /dev/zero in the background. 4.1. Quick Guide on Python...
Page 62
SunFounder pisloth Type y and press Enter to restart the machine. Note: If there is no sound after restarting, you may need to run the i2samp.sh script multiple times. Run servo_zeroing.py Because the servo is powered by the power supply on the Robot HAT, when you only supply power to the Raspberry Pi, the servo will not work.
Page 63
SunFounder pisloth Before you run any code, enable your Raspberry Pi’s I2C port, see: Configuration. Nowrun the servo_zeroing.py in the examples/ folder. cd /home/pi/pisloth/examples sudo python3 servo_zeroing.py To make sure you can see that the servo has been set to 0°, you can insert a rocker arm in the servo shaft first and then turn the servo to another angle.
Note: Before assembling each servo, you need to plug the servo pin into P11 and keep the power on. After the assembly is complete, you can try to run the projects below. 4.2 Move This is the first project. PiSloth has woken up, and it moves freely. Chapter 4. Play with Python...
Page 65
/home/pi/pisloth/examples sudo python3 move.py After running the code, you will see PiSloth move left 7 steps, forward 5 steps, right 7 steps, and forward 5 steps. Code Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path like pisloth\examples.
SunFounder pisloth First, import the Sloth class from the pisloth library you have installed, which contains all of PiSloth’s actions and the functions that implement them. from pisloth import Sloth Then instantiate the Sloth class. sloth Sloth([1,2,3,4]) sloth.set_offset([0,0,0,0]) Finally use the sloth.do_action() function to make PiSloth move.
Page 67
Run the Code cd /home/pi/pisloth/examples sudo python3 dancing.py The whole dance is divided into 2 parts, and PiSloth will finish these 2 parts with the music. If you don’t stop the code, it will repeat the dance. Code Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path like pisloth\examples.
Page 68
You can make PiSloth play music by importing the following libraries. from robot_hat import TTS, Music Play the background music in the pisloth/examples/musics directory and set the volume to 20. You can also add music to the musics folder via Filezilla Software. Chapter 4. Play with Python...
After the code runs, PiSloth will walk forward. If it detects that the distance of the obstacle ahead is less than 10cm, it will stop and sound a warning, then turn left and stop. If there is no obstacle in the direction after turning left or the obstacle distance is greater than 10, it will continue to move forward.
Page 70
• When the distance is less than or equal to alert_distance (the threshold value set earlier, which is 10), play the sound effect sign.wav. PiSloth does hook, stand, left turn and stand in sequence. • When the distance is greater than alert_distance, PiSloth will move forward.
Note: You can add different sound effects or music to musics or sounds folder via Filezilla Software. 4.5 Don’t Touch Me If you don’t meet PiSloth’s needs, it will get angry and stay away from your touch. Run the Code cd /home/pi/pisloth/examples sudo python3 dont_touch_me.py Code Note: You can Modify/Reset/Copy/Run/Stop the code below.
Page 72
• When the distance is less than or equal to alert_distance (the threshold value set earlier, which is 20), play the sound effect talk3.wav and move backward. • When the distance is greater than alert_distance, PiSloth will Stand. distance sonar.read()
SunFounder pisloth 4.6 Let’s Fight! Warrior! Here, PiSloth is a brave warrior, when it appears in front of the enemy, it will let out a roar and rush to the enemy. Note: You can download and print the PDF Cartoon Mask for your PiSloth.
Page 74
• Read the distance detected by ultrasonic module and filter out the values less than 0 (When the ultrasonic module is too far from the obstacle or cannot read the data correctly, distance<0 will appear). • When the distance is between 5 and 40, PiSloth will play warning.wav and attack.mp3 and move forward.
Code Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path like pisloth\examples. After modifying the code, you can run it directly to see the effect. from pisloth import...
Page 77
In this project, actions + sound effects are combined into different emotional actions, and you can also modify them yourself. Note: This fail action will make the PiSloth fall, be careful not to let it fall off the table and break it. You can add different sound effects or music to musics or sounds folder via Filezilla Software.
SunFounder pisloth 4.8 Remote Control In this project, we will learn how to use the keyboard to remotely control the PiSloth. You can control the PiSloth to move up, down, left, and right and speak through specific keys. Run the Code cd /home/pi/pisloth/examples sudo python3 keyboard_control.py...
Page 79
Finally, according to the read keyboard characters, let PiSloth do the actions we set, call the tts.say() function to speak or play the sound effects prepared in advance. 4.8. Remote Control...
/home/pi/pisloth/examples sudo python3 custom_step.py After the code runs, press the key ZX and key NM (according to the actual code) to make PiSloth do the step shown in the figure, and you can also let it do other steps.
Page 81
Custom Action. Code Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path like pisloth\examples. After modifying the code, you can run it directly to see the effect. 4.9. Custom Step...
Page 82
Press keys on keyboard to control PiSloth! Q: Increase the servo angle of the left leg W: Decrease the servo angle of the left leg Z: Increase the servo angle of the left foot...
4.10 Custom Action In the previous project, we were able to give PiSloth custom steps, so how do we combine these steps into actions? For example, have PiSloth make the step from the previous project and then return to the initial position.
Page 84
SunFounder pisloth Note: You can download and print the PDF Cartoon Mask for your PiSloth. Step 1: Go to the /home/pi/pisloth/examples path. cd /home/pi/pisloth/examples Step 2: Open custom_action.py with the following command. nano custom_action.py Step 3: Modify the angle in sloth.add_action(), each group represents a step, and only 2 steps are set here.
Page 85
SunFounder pisloth like pisloth\examples. After modifying the code, you can run it directly to see the effect. from pisloth import Sloth import time sloth Sloth([1,2,3,4]) sloth.add_action("my_action", [ 0,-45 ,0, 40], 0, 0, main(): sloth.do_action("my_action", 1, 80) time.sleep(1) __name__ "__main__": while...
Page 86
SunFounder pisloth Chapter 4. Play with Python...
CHAPTER FIVE APPENDIX 5.1 Filezilla Software The File Transfer Protocol (FTP) is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network. Filezilla is an open source software that not only supports FTP, but also FTP over TLS (FTPS) and SFTP. We can use Filezilla to upload local files (such as pictures and audio, etc.) to the Raspberry Pi, or download files from the Raspberry Pi to the local.
Page 88
SunFounder pisloth Note: Quick Connect is a good way to test your login information. If you want to create a permanent entry, you can select File-> Copy Current Connection to Site Manager after a successful Quick Connect, enter the name and click OK.
SunFounder pisloth 5.2 I2C Configuration Enable the I2C port of your Raspberry Pi (If you have enabled it, skip this; if you do not know whether you have done that or not, please continue). sudo raspi-config 3 Interfacing options P5 I2C...
SunFounder pisloth 5.3 Remote Desktop There are two ways to control the desktop of the Raspberry Pi remotely: VNC and XRDP, you can use any of them. 5.3.1 VNC You can use the function of remote desktop through VNC. Enable VNC service The VNC service has been installed in the system.
Page 92
SunFounder pisloth Step 3 P3 VNC Step 4 Select Yes -> OK -> Finish to exit the configuration. Login to VNC Step 1 You need to download and install the VNC Viewer on personal computer. After the installation is done, open it.
Page 93
SunFounder pisloth Step 2 Then select “New connection”. Step 3 Input IP address of Raspberry Pi and any Name. 5.3. Remote Desktop...
Page 94
SunFounder pisloth Step 4 Double click the connection just created: Chapter 5. Appendix...
Page 95
SunFounder pisloth Step 5 Enter Username (pi) and Password (raspberry by default). 5.3. Remote Desktop...
Page 96
SunFounder pisloth Step 6 Now you can see the desktop of the Raspberry Pi: Chapter 5. Appendix...
Page 97
SunFounder pisloth That’s the end of the VNC part. 5.3.2 XRDP Another method of remote desktop is XRDP, it provides a graphical login to remote machines using RDP (Microsoft Remote Desktop Protocol). Install XRDP Step 1 Login to Raspberry Pi by using SSH.
Page 98
SunFounder pisloth Step 4 Finished the installation, you should login to your Raspberry Pi by using Windows remote desktop applications. Login to XRDP Step 1 If you are a Windows user, you can use the Remote Desktop feature that comes with Windows. If you are a Mac user, you can download and use Microsoft Remote Desktop from the APP Store, and there is not much difference between the two.
Page 99
SunFounder pisloth Then the xrdp login page pops out. Please type in your username and password. After that, please click “OK”. At the first time you log in, your username is “pi” and the password is “raspberry”. Step 4 Here, you successfully login to RPi by using the remote desktop.
SunFounder pisloth 5.4 About the Battery Applicable Parameters • 3.7V • 18650 • Rechargeable • Li-ion Battery • Button Top • No Protective Board Note: • Robot HAT cannot charge the battery, so you need to buy a battery charger.
Page 101
SunFounder pisloth Button Top Flat Top No protective board? You are recommend to use 18650 batteries without a protective board. Otherwise, the robot may be cut power and stop running because of the overcurrent protection of the protective board. Battery capacity? In order to keep the robot working for a long time, use large-capacity batteries as much as possible.
CHAPTER THANK YOU Thanks to the evaluators who evaluated our products, the veterans who provided suggestions for the tutorial, and the users who have been following and supporting us. Your valuable suggestions to us are our motivation to provide better products! Particular Thanks •...
SEVEN COPYRIGHT NOTICE All contents including but not limited to texts, images, and code in this manual are owned by the SunFounder Company. You should only use it for personal study,investigation, enjoyment, or other non-commercial or nonprofit purposes, under therelated regulations and copyrights laws, without infringing the legal rights of the author and relevant right holders.
Need help?
Do you have a question about the PiSloth and is the answer not in the manual?
Questions and answers