import RPi.GPIO as GPIO, time GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) GPIO.setup(27, GPIO.OUT) GPIO.setup(3, GPIO.IN) angle = input("Kakudo = ") direction = raw_input("Houkou = ") if direction == "r" : GPIO.output(17, GPIO.HIGH) GPIO.output(27, GPIO.LOW) else : GPIO.output(17, GPIO.LOW) GPIO.output(27, GPIO.HIGH) b=GPIO.input(3) while True: a=GPIO.input(3) if a != b : time.sleep(0.3) b = a angle = angle - 1 if angle == 0 : GPIO.output(17, GPIO.LOW) GPIO.output(27, GPIO.LOW) break print("end\n") GPIO.cleanup()