# ############################################################################
# ** Proyecto : Led y Boton
# ** Herramienta : https://www.wokwi.com
# ** : Thonny aplicacion de escritorio descargar en www.thonny.org
# ** Compilador : wokwi Simulador online
# ** Version : 1.0
# ** Fecha/Hora : 24-09-2024, 3:45 am,
# **
# ** Descripción del programa :
# ** El programa prende y apaga un led (salida), utlizando un boton (entrada)
# ** con estructura de decisión doble (if / else )
# **
# ** Versión : 1
# ** Revisión : A
# ** Release : 0
# ** Bugs & Fixes :
# ** Date : 24/09/2024
# **
# ** By : Jorge Anzaldo
# ** contact : [email protected]
# ** twitter x : @janzaldob
#############################################################################
# ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# : Librerias / Bibliotecas / Modulos | :
# ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
from machine import Pin #https://docs.micropython.org/en/latest/library/machine.Pin.html
import time #https://docs.micropython.org/en/latest/library/time.html
# +-------------------------------------------------------------------------------
# | V A R I A B L E S / O B J E T O S - I N S T A N C I A S |
# +-------------------------------------------------------------------------------
boton = Pin(4, Pin.IN, Pin.PULL_UP) #Entrada (boton)
led = Pin(15, Pin.OUT) #Salida(led)
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# | Definición y Desarrollo de Funciones |
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# ===============================================================================
# || ||
# || P R O G R A M A / F U N C I O N P R I N C I P A L ||
# || ||
# ===============================================================================
if __name__ == '__main__':
while True:
if boton.value() == 0 :
led.value(1)
else :
led.value(0)
# ********************************************************************************
#
# R E F E R E N C I A S / C O M E N T A R I O S
#
# *********************************************************************************