expression

Translate GPIO polarity into logical state

A GPIO pin is a configurable digital input or output. A button connected using active-low logic is asserted at a low level. Keep the logical meaning separate from the sampled level. This pure function models only polarity; the real board determines pull resistors, pin mode, voltage and electrical limits. Expected host stdout (not executed): high: false, low: true Common mistake: Assuming every button is active-high or that a boolean configures a physical input.

Formal Syntax & Structure

rust syntaxrust
pressed = !pin_high

Working Example

Example Snippetrust
#![no_std]pub fn pressed(pin_high: bool) -> bool { !pin_high }
Rust Reference