Skip to content

Commit

Permalink
active-buzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
ImplFerris committed Nov 12, 2024
1 parent cd96a58 commit 9d54521
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
- [Music module](./buzzer/music-module.md)
- [got module](./buzzer/got-module.md)
- [Play](./buzzer/play.md)
- [Active Beep](./buzzer/active-beep.md)

- [Resources](./resources.md)
55 changes: 55 additions & 0 deletions src/buzzer/active-beep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## Beeping with an Active Buzzer

Since you already know that an active buzzer is simple to use, you can make it beep just by powering it. In this exercise, we'll make it beep with just a little code.


### Hardware Requirements
- **Active Buzzer**
- **Female-to-Male** or **Male-to-Male** (depending on your setup)

We'll use the Embassy HAL for this project.


## Project from template

To set up the project, run:
```sh
cargo generate --git https://github.com/ImplFerris/pico2-template.git
```
When prompted, give your project a name, like "active-beep," and select `embassy` as the HAL.

Then, navigate into the project folder:
```sh
cd PROJECT_NAME
# For example, if you named your project "active-beep":
# cd active-beep
```

All you need to do is change the output pin from 25 to 15 in the template code.

```rust
// Active Buzzer
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let mut led = Output::new(p.PIN_15, Level::Low); // Changed line

loop {
led.set_high();
Timer::after_millis(500).await;

led.set_low();
Timer::after_millis(500).await;
}
}
```


## Clone the existing project
You can clone (or refer) project I created and navigate to the `active-beep` folder.

```sh
git clone https://github.com/ImplFerris/pico2-projects
cd pico2-projects/active-beep
```

5 changes: 5 additions & 0 deletions src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ We will be using the Raspberry Pi Pico 2 (RP2350 chip). It features the new RP2
For detailed technical information, specifications, and guidelines, refer to the official datasheets:
* [Pico 2 Datasheet](https://datasheets.raspberrypi.com/pico/pico-2-datasheet.pdf)
* [RP2350 chip Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)


## Support me

You can support me by starring this project on [GitHub](https://github.com/ImplFerris/pico-pico) or sharing this book with others 😊

0 comments on commit 9d54521

Please sign in to comment.