# Trying to read a digital pin

**URL:** <https://forums.openmv.io/t/trying-to-read-a-digital-pin/8483>\
**Category:** OpenMV Pure Thermal\
**Created:** [June 26, 2023, 8:20pm UTC](https://forums.openmv.io/t/trying-to-read-a-digital-pin/8483 "2023-06-26T20:20:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngativ3](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@ngativ3](https://forums.openmv.io/u/ngativ3)\
**Post date:** [June 26, 2023, 8:20pm UTC](https://forums.openmv.io/t/trying-to-read-a-digital-pin/8483/1 "2023-06-26T20:20:48Z")

</div>

Hey all,

I’m trying to read a digital pin and if I can, I shall try to adjust some camera settings, on the fly.

I get an OpenMV IDE error trying to setup a button as follows:

```auto
button = machine.Pin(9, machine.Pin.IN, machine.Pin.PULL_UP)

```

TypeError: can’t convert ‘int’ objects to str implicitly.

I’m new to this as you can tell, any help offered, appreciated.

---

<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:** [June 28, 2023, 9:40pm UTC](https://forums.openmv.io/t/trying-to-read-a-digital-pin/8483/2 "2023-06-28T21:40:10Z")

</div>

You have to make the PIN number a string.

---

<div class="post-metadata">

**Author:** ![ngativ3](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@ngativ3](https://forums.openmv.io/u/ngativ3)\
**Post date:** [June 29, 2023, 1:48pm UTC](https://forums.openmv.io/t/trying-to-read-a-digital-pin/8483/3 "2023-06-29T13:48:38Z")

</div>

Thanks, yes I got there by the following…

```auto
    pin0 = Pin('P9', Pin.IN, Pin.PULL_UP)
    pinstate0 = pin0.value()

```

Now I’m looking for a reference to the other GPIO pins so I can use them as well.

for example…

```auto
pin1 = Pin('TIM4_CH1', Pin.IN, Pin.PULL_UP)

```

gives an error…

![Untitled-1](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/2X/2/24fd7189dc065ee5eecdafb58885c1008abfaace.png)

---

<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:** [June 29, 2023, 5:32pm UTC](https://forums.openmv.io/t/trying-to-read-a-digital-pin/8483/4 "2023-06-29T17:32:22Z")

</div>

Hi, you use the stuff like this:

```auto
# PWM Control Example
#
# This example shows how to do PWM with your OpenMV Cam.

import time
from pyb import Pin, Timer

tim = Timer(4, freq=1000) # Frequency in Hz
# Generate a 1KHz square wave on TIM4 with 50%, 75% and 50% duty cycles on channels 1, 2 and 3 respectively.
ch1 = tim.channel(1, Timer.PWM, pin=Pin("P7"), pulse_width_percent=50)
ch2 = tim.channel(2, Timer.PWM, pin=Pin("P8"), pulse_width_percent=75)
ch3 = tim.channel(3, Timer.PWM, pin=Pin("P9"), pulse_width_percent=50)

while (True):
    time.sleep_ms(1000)

```

---

<div class="post-metadata">

**Author:** ![ngativ3](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@ngativ3](https://forums.openmv.io/u/ngativ3)\
**Post date:** [June 29, 2023, 7:31pm UTC](https://forums.openmv.io/t/trying-to-read-a-digital-pin/8483/5 "2023-06-29T19:31:17Z")

</div>

Thank you.

I found the pin names on the PCB screen-print.
