#include <stdio.h>
#include "pico/stdlib.h"
#define BUZZER_PIN 0
void buzzer_init(void){
gpio_init(BUZZER_PIN);
gpio_set_dir(BUZZER_PIN, GPIO_OUT);
}
void buzzer_on(void){
gpio_put(BUZZER_PIN, 1);
}
void buzzer_off(void){
gpio_put(BUZZER_PIN, 0);
}
void buzzer_beep(uint8_t num){
if( num <= 0 || num > 255){
num = 1;
}
// beep
for (uint8_t i = 0; i <= num; i++){
gpio_put(BUZZER_PIN, 1);
sleep_ms(200);
gpio_put(BUZZER_PIN, 0);
sleep_ms(200);
}
}
int main() {
stdio_init_all();
buzzer_init();
while (true) {
printf("Hello, Wokwi!\n");
buzzer_on();
sleep_ms(250);
buzzer_off();
sleep_ms(250);
}
}