Blinking leds
Opened this issue · 0 comments
storres20 commented
Raspberry Pi Pinout
URL: https://pinout.xyz/
Esta pagina web muestra 02 distribuciones de PINES (BOARD y BCM)
Para la presente, se utilizará la distribucion de PINES en BCM
Blink Led - Código
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(7, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(12, GPIO.OUT, initial=GPIO.HIGH)
try:
while True:
GPIO.output(7, GPIO.HIGH)
GPIO.output(12, GPIO.LOW)
print("LED on @ GPIO 7")
print("LED off @ GPIO 12")
sleep(1)
GPIO.output(7, GPIO.LOW)
GPIO.output(12, GPIO.HIGH)
print("LED off @ GPIO 7")
print("LED on @ GPIO 12")
sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
Pasos:
-
Crea un nuevo archivo con el nombre 'rpi-blink.py'
-
Inserta el codigo adjunto lineas arriba
-
Al dar doble click en el archivo, este se abrirá con el programa GEANY
-
Al ejecutar el codigo, este se ejecutará en una ventana de la Terminal
-
Para detener la ejecución, presionar Ctrl + C
WhatsApp.Video.2023-04-09.at.12.50.47.AM.mp4
Para mayores detalles, revisar los enlaces de la Bibliografía