// gpio_blinkled.rs - Blinks an LED in a loop. // // Remember to add a resistor of an appropriate value in series, to prevent // exceeding the maximum current rating of the GPIO pin and the LED. // // Interrupting the process by pressing Ctrl-C causes the application to exit // immediately without resetting the pin's state, so the LED might stay lit. // Check out the gpio_blinkled_signals.rs example to learn how to properly // handle incoming signals to prevent an abnormal termination. use std::error::Error; use std::thread; use std::time::Duration; use rppal::gpio::Gpio; // Gpio uses BCM pin numbering. BCM GPIO 23 is tied to physical pin 16. const GPIO_LED: u8 = 23; fn main() -> Result<(), Box> { // Retrieve the GPIO pin and configure it as an output. let mut pin = Gpio::new()?.get(GPIO_LED)?.into_output(); loop { pin.toggle(); thread::sleep(Duration::from_millis(500)); } }