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.rs44
1 files changed, 44 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..2a78a19db
--- /dev/null
+++ b/examples/rp23/src/bin/button.rs
@@ -0,0 +1,44 @@
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 _};
11use embassy_rp::block::ImageDef;
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
28#[embassy_executor::main]
29async fn main(_spawner: Spawner) {
30 let p = embassy_rp::init(Default::default());
31 let mut led = Output::new(p.PIN_25, Level::Low);
32
33 // Use PIN_28, Pin34 on J0 for RP Pico, as a input.
34 // You need to add your own button.
35 let button = Input::new(p.PIN_28, Pull::Up);
36
37 loop {
38 if button.is_high() {
39 led.set_high();
40 } else {
41 led.set_low();
42 }
43 }
44}