Untitled
unknown
plain_text
2 years ago
494 B
10
Indexable
import RPi.GPIO as GPIO
import time
channel = 21
# GPIO setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.OUT)
def motor_on(pin):
GPIO.output(pin, GPIO.HIGH) # Turn motor on
def motor_off(pin):
GPIO.output(pin, GPIO.LOW) # Turn motor off
if __name__ == '__main__':
try:
motor_on(channel)
time.sleep(1)
motor_off(channel)
time.sleep(1)
GPIO.cleanup()
except KeyboardInterrupt:
GPIO.cleanup()Editor is loading...