EasyManua.ls Logo

SunFounder PiCrawler Kit - Page 58

Default Icon
137 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 PiCrawler Kit
Run the Code
cd /home/pi/picrawler/examples
sudo python3 avoid.py
After the code runs, PiCrawler 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.
Code
Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path
like picrawler\examples. After modifying the code, you can run it directly to see the effect.
from picrawler import Picrawler
from robot_hat import TTS, Music
from robot_hat import Ultrasonic
from robot_hat import Pin
import time
import os
tts = TTS()
music = Music()
(continues on next page)
54 Chapter 3. Play with Python

Other manuals for SunFounder PiCrawler Kit

Related product manuals