Ich arbeite an einem kleinen Projekt mit Servos auf der Raspberry Pi
. Ich wollte die Servos für x Zeit laufen und dann aufhören. Ich habe meinen Code ausprobiert und erhalte derzeit eine ungültige Syntax unter "def sleeper"
und habe keine Ahnung warum.Ungültige Syntax auf "def Schläfer"
Da auch Stackofflow neu ist, hatte ich einige Probleme mit dem Code, ich entschuldige mich!
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
try:
while True:
GPIO.output(7,1)
time.sleep(0.0015)
GPIO.output(7,0)
def sleeper():
while True:
num = input('How long to wait: ')
try:
num = float(num)
except ValueError:
print('Please enter in a number.\n')
continue
print('Before: %s' % time.ctime())
time.sleep(num)
print('After: %s\n' % time.ctime())
try:
sleeper()
except KeyboardInterrupt:
print('\n\nKeyboard exception received. Exiting.')
exit()
Bitte formatieren Sie Ihren Code. – ozgur