aboutsummaryrefslogtreecommitdiff
path: root/examples/rp23/src/bin/button.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/rp23/src/bin/button.rs')
-rw-r--r--examples/rp23/src/bin/button.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/rp23/src/bin/button.rs b/examples/rp23/src/bin/button.rs
new file mode 100644
index 000000000..0a0559397
--- /dev/null
+++ b/examples/rp23/src/bin/button.rs
@@ -0,0 +1,43 @@
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::block::ImageDef;
10use embassy_rp::gpio::{Input, Level, Output, Pull};
11use {defmt_rtt as _, panic_probe as _};
12
13#[link_section = ".start_block"]
14#[used]
15pub static IMAGE_DEF: ImageDef = ImageDef::secure_exe();
16
17// Program metadata for `picotool info`
18#[link_section = ".bi_entries"]
19#[used]
20pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 4] = [
21 embassy_rp::binary_info_rp_cargo_bin_name!(),
22 embassy_rp::binary_info_rp_cargo_version!(),
23 embassy_rp::binary_info_rp_program_description!(c"Blinky"),
24 embassy_rp::binary_info_rp_program_build_attribute!(),
25];
26
27#[embassy_executor::main]
28async fn main(_spawner: Spawner) {
29 let p = embassy_rp::init(Default::default());
30 let mut led = Output::new(p.PIN_25, Level::Low);
31
32 // Use PIN_28, Pin34 on J0 for RP Pico, as a input.
33 // You need to add your own button.
34 let button = Input::new(p.PIN_28, Pull::Up);
35
36 loop {
37 if button.is_high() {
38 led.set_high();
39 } else {
40 led.set_low();
41 }
42 }
43}