Need support? support.freenove.com
Chapter 7 Smart video car
Open the terminal and use the following command to enter the directory where test_Code.py is located:
cd ~/Desktop/Test
Run test_Code.py:
sudo python test_Code.py
Code example
Following are code example for the parts. For more detail, please refer to Module test section.
For more details, please refer to Motor.
from Motor import * #import Motor
PWM=Motor() #create an object
PWM.setMotorModel(2000,2000,2000,2000) #Forward
time.sleep(3) #waiting 3 second
PWM.setMotorModel(0,0,0,0) #Stop
ADC. For more details, please refer to ADC.
from ADC import * #import ADC
adc=Adc() #create an object
Left_IDR=adc.recvADC(0) #get value
print ("The photoresistor voltage on the left is "+str(Left_IDR)+"V")
LED. For more details, please refer to LED.
from Led import * #import Led
led=Led() #create an object
led.ledIndex(0x04,255,255,0) #yellow
led.ledIndex(0x80,0,255,0) #green
time.sleep(5) #wait 5s
led.colorWipe(led.strip, Color(0,0,0)) #turn off