import machine
import utime

# this is a pico program, I think

# external set up of GPIO Pins
# GP15 to red (n.o.) button to 3v3
# GP10 to 330 ohm resistor to greenLED anode from cathode to GND Pin phys 23
# GP11 to 330 ohm resistor to redLED   anode from cathode to GND Pin phys 23

# for the MakerPiPro use GP20 for button_red (with a PULL_UP)

button_red = machine.Pin(20, machine.Pin.IN, machine.Pin.PULL_UP)
led_red  = machine.Pin(10, machine.Pin.OUT)
led_green  = machine.Pin(25, machine.Pin.OUT)  #GP25 is the on-board Green LED

# inititialize red and green LEDs
led_red.value(0)
led_green.value(0)

def int_handler(pin):
	button_red.irq(handler=None)
	print("Interrupt Detected!")
	led_red.value(1)
	led_green.value(0)
	utime.sleep(4)	# seconds
	led_red.value(0)
	button_red.irq(handler=int_handler)
#def end

button_red.irq(trigger=machine.Pin.IRQ_RISING, handler=int_handler)

# toggles the main green led on the pico !!
while True:
	led_green.toggle()
	utime.sleep(2)  # seconds
#while end

# source: https://www.youtube.com/watch?v=Zy64kZEM_bg
#/intRed.py     stored as intRed_py.txt
