-1
嗨我有幾個問題與我的代碼(變量),如果有人知道什麼是錯誤的我會非常感謝聽到我做錯了,因爲我一直在嘗試幾個小時結束。非常感謝詹姆斯。Var in python 2.7
import time
import RPi.GPIO as GPIO
# Next we setup the pins for use!
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(18,GPIO.OUT)
#foward, left, right
foward = print("Foward")
GPIO.output(17, True)
GPIO.output(18, True)
time.sleep(3)
left = print("Left")
GPIO.output(17, True)
GPIO.output(18, False)
time.sleep(3)
Right = print("Right")
GPIO.output(17, False)
GPIO.output(18, True)
time.sleep(3)
print('Starting motor sequence!')
while True:
try:
foward
left
right
right
right
foward
foward
這就是現在你如何定義功能和使用功能。 – MooingRawr
你應該閱讀:https://docs.python.org/3/tutorial/controlflow.html#defining-functions – n1c9
你可以這樣做,我可以問你 –