# Digital read Nicla Vision

**URL:** <https://forums.openmv.io/t/digital-read-nicla-vision/8920>\
**Category:** Arduino Boards\
**Created:** [November 7, 2023, 3:30pm UTC](https://forums.openmv.io/t/digital-read-nicla-vision/8920 "2023-11-07T15:30:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@andrea](https://forums.openmv.io/u/andrea)\
**Post date:** [November 7, 2023, 3:30pm UTC](https://forums.openmv.io/t/digital-read-nicla-vision/8920/1 "2023-11-07T15:30:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [November 7, 2023, 7:19pm UTC](https://forums.openmv.io/t/digital-read-nicla-vision/8920/2 "2023-11-07T19:19:08Z")

</div>

Here you go: [class Pin – control I/O pins — MicroPython 1.20 documentation](https://docs.openmv.io/library/machine.Pin.html)

---

<div class="post-metadata">

**Author:** ![andrea](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@andrea](https://forums.openmv.io/u/andrea)\
**Post date:** [November 8, 2023, 11:10am UTC](https://forums.openmv.io/t/digital-read-nicla-vision/8920/3 "2023-11-08T11:10:57Z")

</div>

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):

```auto
// 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) {
    Serial.println(1);
  } else {
    Serial.println(0);
  }
  delay(50);
}

```

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

```auto
import time
from pyb import Pin

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

while True:
    #Read
    button_state = p3.value()

    # Print lable
    if button_state == 0:
        print("0")
    else:
        print("1")

    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,

Andrew

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [November 8, 2023, 7:29pm UTC](https://forums.openmv.io/t/digital-read-nicla-vision/8920/4 "2023-11-08T19:29:56Z")

</div>

Hi, try:

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

```

or

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

```

---

<div class="post-metadata">

**Author:** ![andrea](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@andrea](https://forums.openmv.io/u/andrea)\
**Post date:** [November 9, 2023, 7:45am UTC](https://forums.openmv.io/t/digital-read-nicla-vision/8920/5 "2023-11-09T07:45:47Z")

</div>

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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![iabdalkader](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/iabdalkader/32/1169_2.png) [@iabdalkader](https://forums.openmv.io/u/iabdalkader)\
**Post date:** [November 9, 2023, 3:41pm UTC](https://forums.openmv.io/t/digital-read-nicla-vision/8920/6 "2023-11-09T15:41:45Z")

</div>

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