Processor

【라즈베리파이】 wiringPi Python : LED 제어하기

작성자 임베디드코리아 작성일26-02-20 00:10 조회77회 댓글0건
◆ GPIO 18번 핀을 사용하여 불을 0.5초 간격으로 껏다 켰다 하는 프로그램
--->>> GPIO_led.py  <<<-------------------------------
import RPi.GPIO as GPIO
import time
 
GPIO.setmode(GPIO.BCM)
 
LED = 18
 
GPIO.setup(LED, GPIO.OUT, initial=GPIO.LOW)
 
try:
    while 1:
      GPIO.output(LED, GPIO.HIGH) # 불 켜기
        time.sleep(0.5)
      GPIO.output(LED, GPIO.LOW) # 불 끄기
        time.sleep(0.5)
 
except KeyboardInterrupt:
    pass
 
GPIO.cleanup()