Skip to content
Snippets Groups Projects
Commit 7939b812 authored by DenysVolo's avatar DenysVolo
Browse files

added variable buzzer files

parent 27e9a4f2
Branches
No related tags found
No related merge requests found
#include "pico/stdlib.h"
int main() {
uint buzzer = 18;
gpio_init(buzzer);
gpio_set_dir(buzzer, GPIO_OUT);
uint buzzerSlower = 20;
gpio_init(buzzerSlower);
gpio_set_dir(buzzerSlower, GPIO_IN);
uint buzzerFaster = 21;
gpio_init(buzzerFaster);
gpio_set_dir(buzzerFaster, GPIO_IN);
int delay = 100;
while (true) {
if (gpio_get(buzzerSlower) == 0) {
delay += 10;
sleep_ms(delay);
} else if (gpio_get(buzzerFaster) == 0) {
if (delay > 11) {
delay -= 10;
}
sleep_ms(delay);
} else {
gpio_put(buzzer,1);
sleep_ms(delay);
gpio_put(buzzer,0);
sleep_ms(delay);
}
}
}
\ No newline at end of file
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment