Untitled
plain_text
a month ago
494 B
1
Indexable
Never
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()