from machine import Pin, freq
import time

outputPin = Pin(27, Pin.OUT, value=0)
irPin = Pin(26, Pin.IN, Pin.PULL_UP)

isOpen = False
isMoving = False

while True:
  time.sleep(0.04)
  isPressed = irPin.value() == 0

  # if isPressed:
    # print(isPressed)

  if isPressed:
    isMoving = not isMoving

  # if(irPin.value() == 1) {
    # isOpen = !isOpen
    # isMoving = not isMoving
  # }
  # print(isMoving, irPin.value() == 1)
  print(isMoving, isPressed)
  # outputPin.value(isOpen ? 1 : 0)