terra121

RPI Blinking

Feb 12th, 2025
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import RPi.GPIO as GPIO
  2. import time
  3.  
  4. # Configuración del pin
  5. led = 17  # GPIO donde está el LED
  6. GPIO.setmode(GPIO.BCM)  # Usar numeración BCM
  7. GPIO.setup(led, GPIO.OUT)  # Configurar como salida
  8.  
  9. try:
  10.     while True:
  11.         GPIO.output(led, GPIO.HIGH)  # Encender LED
  12.         print("LED Encendido")
  13.         time.sleep(1)
  14.         GPIO.output(led, GPIO.LOW)  # Apagar LED
  15.         print("LED Apagado")
  16.         time.sleep(1)
  17. except KeyboardInterrupt:
  18.     print("Saliendo...")
  19.     GPIO.cleanup()  # Restablecer configuración de los GPIO
  20.  
Tags: raspberry
Advertisement
Add Comment
Please, Sign In to add comment