Mraa program with pull-up resistor

I want to code using a pull-up resistor. However, I don’t know the correct coding. I tried it, but I would like to know if the following coding is correct.

Connect the button switch to pin 3 and GND to read the ON/OFF status of the switch.


import mraa
import time

gpio_sw = mraa.Gpio(3)

gpio_sw.inputMode(mraa.MODE_IN_ACTIVE_HIGH)

time.sleep(1)

gpio_sw.dir(mraa.DIR_IN)
while True:
result = gpio_sw.read()
print(result)
time.sleep(0.1)


Thank you for your support.

@Nasca can you give some advice ?

Boards apart from Intel’s edison seems to not support programmatic pull-ups.

1 Like

Thank you for your reply.

I have understood that is not recommended in Rock4c+ now.

Then,
there is a description of pull-up resistors in the “Radxa ROCK 4C+ Product Brief”, but should I not use them?

Please note that pin 3, 5, 27, 28, 29 and 31 have a 4K7 pull up resistor to 3V.

I mean the pull-up and pull-down functionality of mraa may still have some issues, as detailed here.

1 Like

I have understood that pull-up and pull-down functionality of mraa is pending approval.
Unfortunately, I will refrain from using it until your request is approved.

Thank you for taking the time to respond.