print("Hello, ESP32!")
#####################################
###### IMPORT LIBRARIES
from machine import Pin
from time import sleep
#####################################
###### PIN CONFIGURATIONS
# Configure the LED and Pushbutton pins
pin_led = Pin(21, Pin.OUT)
pin_pb = Pin(2, Pin.IN)
#####################################
###### SUBROUTINE FOR INTERRUPT #####
#####################################
def interrupt_pb(pin):
print('Interrupt by:', pin)
pin_led.on()
sleep(1)
pin_led.off()
sleep(1)
# Interrupt trigger when rising
pin_pb.irq(trigger=Pin.IRQ_RISING, handler=interrupt_pb)
#####################################
###### MAIN ROUTINE
def main():
while True:
# LED stays off unless interrupted
pin_led.off()
sleep(10)
#####################################
###### EXECUTE MAIN ROUTINE
if __name__ == '__main__':
main()