EasyManua.ls Logo

SunFounder PiSloth - Let’s Fight! Warrior!

SunFounder PiSloth
113 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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.
Run the Code
cd /home/pi/pisloth/examples
sudo python3 lets_fight.py
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.
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 Sloth
from robot_hat import Music
from robot_hat import Ultrasonic
from robot_hat import Pin
import time
import os
(continues on next page)
4.6. Let’s Fight! Warrior! 87

Related product manuals