-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd96a58
commit 9d54521
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters