Switch pin beetween input and output mode #662
Replies: 3 comments
-
Please describe what problem you are hitting and which piece of your code you think is responsible. Don't expect others to just decipher your code to understand what's your problem. |
Beta Was this translation helpful? Give feedback.
-
Excuse me. Mistake is here
In short. I misunderstood how to correctly borrow pins value if i need switch pin mode in loop. Also if i need pass that pin value to fn. |
Beta Was this translation helpful? Give feedback.
-
So in your particular situation, you can solve this by explicitly converting the pin back into its original mode: let mut dht_pin_out = pins.d2.into_opendrain_high();
loop {
dht_pin_out.set_low();
let mut dht_pin_in = dht_pin_out.into_pull_up_input();
// then, later
dht_pin_out = dht_pin_in.into_opendrain_high();
} For more dynamic situations or when you only hold a reference to a pin, there will be #205 which unfortunately is not finished yet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How to make it work?
Beta Was this translation helpful? Give feedback.
All reactions