Files
2026-07-11 16:59:05 -07:00

26 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
tags:
- resource
created: 2025-11-06 17:37
---
## Summary
Notes on the use of the [rppal]() crate.
## Notes
### GPIO Pull Up/Pull Down Bias
The `rppal::gpio::InputPin::set_bias` method is used to configure the Raspberry Pi's **built-in pull-up or pull-down resistors** on an input pin. 
You should use `set_bias` when interfacing with digital input sensors or switches that do not have their own external pull-up/pull-down resistors. These internal resistors ensure the input pin has a defined logic level (either high or low) when the external component is disconnected or floating, preventing erratic readings caused by electrical noise. 
| When to Use | Typical Connection | |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| **`Bias::PullUp`** | When the input is connected to ground (GND) to signal a "low" state (e.g., a button connecting the pin to GND). The resistor pulls the pin voltage up to 3.3V by default. | One side of a button to the GPIO pin, the other side to GND. |
| **`Bias::PullDown`** | When the input is connected to 3.3V to signal a "high" state (e.g., a sensor outputting 3.3V). The resistor pulls the pin voltage down to GND by default. | One side of a button to the GPIO pin, the other side to 3.3V. |
| **`Bias::Off`** | When the external circuit already provides a defined logic level (e.g., an active sensor with a strong output signal, or an external pull-up/pull-down resistor is used). | Active sensor output connected directly to the GPIO pin. |
## References