Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO still on after program exit #7

Closed
hasanAjsf opened this issue Sep 12, 2019 · 1 comment
Closed

GPIO still on after program exit #7

hasanAjsf opened this issue Sep 12, 2019 · 1 comment

Comments

@hasanAjsf
Copy link

Hi,

I just wrote my first prgram:

use rust_gpiozero::*;
use std::thread::sleep;
use std::time::Duration;

fn main() {
    let mut yellow = LED::new(21);
    let mut red = LED::new(26);
    loop{
       red.on();
       yellow.off();
       sleep(Duration::from_millis(200));
        yellow.on();
        sleep(Duration::from_millis(200));
        red.off();
        sleep(Duration::from_millis(200));
    }
}

Once pressing Ctrl+C the program is exit but the Led still on, even if I removed the wire and returned it, to the GPIO it still on!

@rahul-thakoor
Copy link
Owner

hey there,
Given that Rust doesn't catch ctrl-c or SIGTERM, you can use simple signal to handle those.

You can check the example here and adapt it for your code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants