EasyManuals Logo

Freenove 4WD Smart Car Board for Raspberry Pi User Manual

Default Icon
132 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #85 background imageLoading...
Page #85 background image
Need support? support.freenove.com
81
Chapter 3 Module test (necessary)
www.freenove.com
Result:
Every 1s, the distance between the obstacle and the ultrasonic module will be printed out, and you can press
"Ctrl + C" to end the program.
The code is as below:
1
2
3
4
5
6
7
8
9
10
from Ultrasonic import *
ultrasonic=Ultrasonic()
def test_Ultrasonic():
try:
while True:
data=ultrasonic.get_distance() #Get the value
print ("Obstacle distance is "+str(data)+"CM")
time.sleep(1)
except KeyboardInterrupt:
print "\nEnd of program"
Reference
get_distance()
This function is used to obtain the distance between ultrasonic module and obstacles in front of it, with unit
CM.

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove 4WD Smart Car Board for Raspberry Pi and is the answer not in the manual?

Freenove 4WD Smart Car Board for Raspberry Pi Specifications

General IconGeneral
BrandFreenove
Model4WD Smart Car Board for Raspberry Pi
CategoryMicrocontrollers
LanguageEnglish