30 lines
810 B
Python
Executable File
30 lines
810 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import RPi.GPIO as GPIO
|
|
import time
|
|
import atexit
|
|
|
|
# Configuraciones
|
|
LED_PIN = 16 # Número del pin BCM donde está conectado el LED
|
|
|
|
def cleanup():
|
|
"""Apaga el LED y limpia los recursos de GPIO al salir."""
|
|
GPIO.output(LED_PIN, GPIO.LOW)
|
|
GPIO.cleanup()
|
|
|
|
def main():
|
|
# Configuración inicial del GPIO
|
|
GPIO.setmode(GPIO.BCM)
|
|
GPIO.setup(LED_PIN, GPIO.OUT, initial=GPIO.HIGH)
|
|
|
|
# Registrar la función de limpieza al salir
|
|
atexit.register(cleanup)
|
|
|
|
# Aquí podrías dejarlo encendido o realizar otras tareas.
|
|
# Este script simplemente deja el LED encendido al iniciar.
|
|
# while True:
|
|
# time.sleep(60) # Evita que el script termine. Puedes ajustar esto o eliminarlo si solo necesitas encender el LED.
|
|
|
|
if __name__ == "__main__":
|
|
main()
|