summaryrefslogtreecommitdiff
path: root/examples/rp/src/bin/button.rs
blob: a7846cbf3f307e0b7be5095173b98c457a4a6f15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![no_std]
#![no_main]
#![feature(asm)]
#![feature(type_alias_impl_trait)]

#[path = "../example_common.rs"]
mod example_common;

use embassy::executor::Spawner;
use embassy_rp::gpio::{Input, Level, Output, Pull};
use embassy_rp::Peripherals;

#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
    let button = Input::new(p.PIN_28, Pull::Up);
    let mut led = Output::new(p.PIN_25, Level::Low);

    loop {
        if button.is_high() {
            led.set_high();
        } else {
            led.set_low();
        }
    }
}