Louie NRT Story

[RaspberryPi] Led Control 본문

에너지

[RaspberryPi] Led Control

hyeok0724.kim@gmail.com 2020. 2. 3. 14:02
반응형

Writed: 3 FEB 2020

 

1. Circuit diagram

2. GPIO Pin

 

3. Code

1) Use BCM

import RPi.GPIO as GPIO
import time

LED_PIN = 17
led_status = True

GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)

try:
	while True:
		GPIO.output(LED_PIN, led_status)
		print("LED_Status = ")
		print(led_status)
		led_status ^= True
		time.sleep(5)
		
except KeyboardInterrupt:
	GPIO.cleanup()

2) Use Board

import RPi.GPIO as GPIO
import time

LED_PIN = 11
led_status = True

GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED_PIN, GPIO.OUT)

try:
	while True:
		GPIO.output(LED_PIN, led_status)
		print("LED_Status = ")
		print(led_status)
		led_status ^= True
		time.sleep(5)
		
except KeyboardInterrupt:
	GPIO.cleanup()

 

4. ETC

 GPIO.setup(11, GPIO.OUT)
 #or
 GPIO.setup(11, GPIO.IN)

 

5. Reference

http://lhdangerous.godohosting.com/wiki/index.php/Raspberry_pi_%EC%97%90%EC%84%9C_python%EC%9C%BC%EB%A1%9C_GPIO_%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0

반응형

'에너지' 카테고리의 다른 글

[LoRa] SystemBase Inc. uLory  (0) 2020.02.04
[BlueTooth] HC-06  (0) 2020.02.03
[나인와트] 2019 Incheon Civic Hack-Fair  (0) 2020.01.05
[기본상식] App 만드는 방법  (0) 2019.12.26
[Node MCU ESP8266] Monitoring DHT11 via thingspeak  (0) 2019.12.24
Comments