aboutsummaryrefslogtreecommitdiff
path: root/examples/rp235x/src/bin/button.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/rp235x/src/bin/button.rs')
-rw-r--r--examples/rp235x/src/bin/button.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/rp235x/src/bin/button.rs b/examples/rp235x/src/bin/button.rs
new file mode 100644
index 000000000..4ad2ca3b7
--- /dev/null
+++ b/examples/rp235x/src/bin/button.rs
@@ -0,0 +1,28 @@
1//! This example uses the RP Pico on board LED to test input pin 28. This is not the button on the board.
2//!
3//! It does not work with the RP Pico W board. Use wifi_blinky.rs and add input pin.
4
5#![no_std]
6#![no_main]
7
8use embassy_executor::Spawner;
9use embassy_rp::gpio::{Input, Level, Output, Pull};
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 let p = embassy_rp::init(Default::default());
15 let mut led = Output::new(p.PIN_25, Level::Low);
16
17 // Use PIN_28, Pin34 on J0 for RP Pico, as a input.
18 // You need to add your own button.
19 let button = Input::new(p.PIN_28, Pull::Up);
20
21 loop {
22 if button.is_high() {
23 led.set_high();
24 } else {
25 led.set_low();
26 }
27 }
28}