print("Hello, ESP32!")
#####################################
###### IMPORT LIBRARIES
from machine import Pin
from time import sleep
#####################################
###### PIN CONFIGURATIONS
# Configure the pin as output
# Replace the x & y with your GPIO Pin X number here
pin_led = Pin(15, Pin.OUT)
pin_pb = Pin(14, Pin.IN)
#####################################
###### MAIN ROUTINE
def main():
while True:
# always OFF
pin_led.off()
sleep(10)
#####################################
###### SUBROUTINE FOR INTERRUPT
# create a function to be called when the trigger occurs
# this function just toggles the onboard LED
def interrupt_pb(pin):
print('Interrupt by:', pin)
pin_led.on()
sleep(5)
pin_led.off()
# Interrupt trigger
pin_pb.irq(trigger=Pin.IRQ_FALLING, handler=interrupt_pb)
#####################################
###### EXECUTE MAIN ROUTINE
if __name__ == '__main__':
main()