라즈베리파이 led

arduino_2020. 5. 18. 22:30
from RPi import GPIO
import time


class LED():
    
    def __init__(self):
        
        GPIO.setmode(GPIO.BOARD) 
        self.ledRed = 11

    def pinSetup(self):
        
        GPIO.setup(self.ledRed, GPIO.OUT, initial=GPIO.LOW)
    
    def pinOn(self):
        
        try:

            while True:
                
                try:
                    # ===================
                    # led on !!
                    # ===================
                    GPIO.output (self.ledRed, GPIO.HIGH)
                except:
                    print("led on error !!")
                    beak
                else:
                    time.sleep(0.5)
                    print("redPing on!!")
                
                try:
                    # ===================
                    # led off !!
                    # ===================
                    GPIO.output (self.ledRed, GPIO.LOW)
                except:
                    print("led off error !!")
                    break
                else:
                    time.sleep(0.5)
                    print("redPing off!!")

        except KeyboardInterrupt as e:
            print(e)
            pass 
        
        GPIO.cleanup()

        print("cleanup !!")


############################
# program main function
# writer : JunHyeon.kim
############################
if __name__ == "__main__":
    
    o = LED()
    o.pinSetup()
    o.pinOn()

'arduino_' 카테고리의 다른 글

라즈베리파이 온도습도 센서  (0) 2020.05.18
four led ver2  (0) 2017.10.10
LED _VER2 FOUR  (0) 2017.10.10
four led  (0) 2017.10.10
sds011 - 먼지 센서  (0) 2017.09.21