EasyManua.ls Logo

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

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
66
Chapter 3 Module test (necessary)
The code is as below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from ADC import *
adc=Adc()
def test_Adc():
try:
while True:
Left_IDR=adc.recvADC(0)
print ("The photoresistor voltage on the left is "+str(Left_IDR)+"V")
Right_IDR=adc.recvADC(1)
print ("The photoresistor voltage on the right is "+str(Right_IDR)+"V")
Power=adc.recvADC(2)
print ("The battery voltage is "+str(Power*3)+"V")
time.sleep(1)
print '\n'
except KeyboardInterrupt:
print "\nEnd of program"
Reference
recvADC(channel)
This function has only one input parameter, which can be 0, 1 or 2.
When the input is 0, the value of this function is the voltage value of the left photoresistor.
When the input is 1, the value of this function is the voltage value of the right photoresistor.
When the input is 2, the value of this function is the voltage value of each battery. After multiplying by 3,
it is the actual battery voltage value