PI : Python On Delay 10 Seconds
การต่อ
Code Python
- import RPi.GPIO as GPIO
- import time
- stop_time = time.time() + 10
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(10,GPIO.OUT)
- try:
- while time.time() < stop_time:
- GPIO.output(10,1)
- time.sleep(0.0015)
- GPIO.output(10,0)
- time.sleep(0.01)
- except KeyboardInterrupt:
- pass
- print"Stopping Auto-Feeder"
- GPIO.cleanup()
No comments:
Post a Comment