STM32点蜂鸣器

张开发
2026/4/17 20:19:22 15 分钟阅读

分享文章

STM32点蜂鸣器
这是一个峰鸣器GND接stm32的GNDVCC接3.3Vi/o接你设置的引脚代码如下void Bear_int(){ GPIO_InitTypeDef Bear_initstruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); Bear_initstruct.GPIO_PinGPIO_Pin_3; Bear_initstruct.GPIO_SpeedGPIO_Speed_10MHz; Bear_initstruct.GPIO_Mode GPIO_Mode_Out_PP; GPIO_Init(GPIOA, Bear_initstruct); }这是我初始化引脚的代码内容和点亮led32差不多就不讲了下面是主函数的代码#include stm32f10x.h #include main.h #include led.h #include bear.h int main() { Bear_int(); while(1){ GPIO_ResetBits(GPIOA, GPIO_Pin_3); } }很简单一个while循环一个设置低电平输出就结束了

更多文章