-- outside door port.b -- inside door port.c -- outside button pin.a -- inside button pin.d -- Outside button is pressed if event.type == 'on' and event.pin.name == 'A' then interrupt(1, 'close_all_doors') interrupt(3, 'open_outside_door') end -- Inside button is pressed if event.type == 'on' and event.pin.name == 'D' then interrupt(1, 'close_all_doors') interrupt(3, 'open_inside_door') end -- Open the other door if event.type == 'interrupt' then if event.iid == 'open_outside_door' then port.c = false port.b = true interrupt(5, 'close_all_doors') end if event.iid == 'open_inside_door' then port.c = true port.b = false interrupt(5, 'close_all_doors') end end -- Close all doors after any button press if event.type == 'interrupt' and event.iid == 'close_all_doors' then port.b = false port.c = false end