라즈베리파이 LED예제

Posted by PeEn
2019. 9. 5. 11:27 Programing/Raspberry Pi)
import RPi.GPIO as gpio
import time
import sys
import warnings
warnings.filterwarnings('ignore')

LED = 4

if __name__ == '__main__' :
    
    gpio.setmode(gpio.BCM)
    gpio.setup(LED, gpio.OUT)

    try:
       while True:
           gpio.output(LED, gpio.HIGH)
           time.sleep(1)
           
           gpio.output(LED, gpio.LOW)
           time.sleep(1)
    except KeyboardInterrupt:
        gpio.cleanup()
        sys.exit()