Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4971

General • Bidirectional GPIO

$
0
0
I am trying to use the GPIO3 pin to do bidirectional IO with the Pico SDK. I am porting an application which was written using another library for the Pico where it worked as expected.

In my implementation, writing to the pin with gpio_put works without a problem. I am initialising the pin as follows

Code:

gpio_init(PIN3);gpio_set_dir(PIN3, GPIO_OUT);gpio_put(PIN3, 0);
To read from the pin, I change the direction with the following function

Code:

gpio_set_dir(PIN3, GPIO_IN);
The pin appears to be always low on the oscilloscope. Using gpio_get I always get a 0. What is the correct way to switch a pin from output to input?

Statistics: Posted by szoshi — Wed Jan 24, 2024 7:11 am



Viewing all articles
Browse latest Browse all 4971

Trending Articles