EasyManua.ls Logo

Freenove 4WD Smart Car Board for Raspberry Pi - Page 72

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
Loading...
Need support? support.freenove.com
68
Chapter 3 Module test (necessary)
The code is as below:
1
2
3
4
5
6
7
8
9
10
11
12
from Infrared_Obstacle_Avoidance import *
def test_Infrared():
try:
while True:
if GPIO.input(IR01)!=True and GPIO.input(IR02)==True and GPIO.input(IR03)!=True:
print 'Middle'
elif GPIO.input(IR01)!=True and GPIO.input(IR02)!=True and GPIO.input(IR03)==True:
print 'Right'
elif GPIO.input(IR01)==True and GPIO.input(IR02)!=True and GPIO.input(IR03)!=True:
print 'Left'
except KeyboardInterrupt:
print "\nEnd of program"
Reference
GPIO.input(IO)
This function has an input parameter. If the IO input is high level, GPIO.input(IO) returns True. If the IO input
is low level, GPIO.input(IO) returns False.