Digital read Nicla Vision

Buongiorno a tutti, sto cercando un esempio di codice Open MV per gestire il pin 5 (ovvero D3/LPIO3) come ingresso digitale.

sarebbe sufficiente un esempio di codice per accendere il led di sistema quando il segnale digitale su D3 diventa vero.

grazie mille!

Here you go: class Pin – control I/O pins — MicroPython 1.20 documentation

Thank you very much for your answer, however it is not clear how it works. I’ll give you an example:

Your Arduino IDE works like this (with R=1.5k of PullDown):

// constants won't change. They're used here to set pin numbers:
const int buttonPin = D3;     // the number of the pushbutton pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
  } else {

I expect it will also work on OpenMV with this sketch:

import time
from pyb import Pin

# Creates a Pin object associated with pin D3 
p3 = Pin("D3", Pin.IN, None)

while True:
    button_state = p3.value()

    # Print lable
    if button_state == 0:

    time.sleep(0.1)  #delay

however I don’t have the same result, where am I going wrong? also consider that the circuit configuration is the same.

Thank you,


Hi, try:

p3 = Pin("D3", Pin.IN, Pin.PULL_NONE)


p3 = Pin("D3", Pin.IN)

Good morning everyone!

Thank you very much for your answers, however I recently found the solution, and it’s trivial!

Even if on Arduino IDE the PIN is called D3, here on open MV its name will be “PG1”, so it works like this:

button = Pin("PG1", Pin.IN)

in the same way we will have:

A0 → PC4
A1 → PF13
A2 → PF3
D2 → PA10
D1 → PA9

Let me know if this is the case for you too.

Thank you! Soon!

I fixed the mapping of those pins for Nicla Vision, in the next firmware release you’ll be able to use Ax and Dx.