Now you can open OpenMV IDE and write to our program. To read GPIO value, you can use value(). If we want to write digital I/O, you can use value(1) for writing HIGH and value(0) for writing LOW.
The following is completed code.
from pyb import Pin print('demo digital I/O') led = Pin('P0', Pin.OUT_PP) button = Pin('P1', Pin.IN, Pin.PULL_UP) while 1: state = button.value() if state > 0: led.value(1) else: led.value(0)
Save this as ledbutton.py.