print("Hello, ESP32!")
# IMPORT LIBRARIES
from machine import Pin
from time import sleep
# PIN CONFIGURATIONS
led_pin = Pin(16, Pin.OUT)
button_pin = Pin(14, Pin.IN, Pin.PULL_UP)
# MAIN ROUTINE
def main():
while True:
# Turn off LED initially
led_pin.value(0)
sleep(10) # Wait 10 seconds
#####################################
# SUBROUTINE FOR INTERRUPT
# Function called when button is pressed (falling edge)
def interrupt_pb(pin):
print('Button pressed!')
led_pin.value(1) # Turn on LED
sleep(5) # Wait for 5 seconds
led_pin.value(0) # Turn off LED
# Interrupt Trigger
button_pin.irq(trigger=3, handler=interrupt_pb)
#####################################
# EXECUTE MAIN ROUTINE
if __name__ == '__main__':
main()