#include "stm32f10x.h" // Device header
#include "Delay.h"
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); //唤醒时钟
GPIO_InitTypeDef GPIO_InitStructure; // 局部变量声名
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; //输出模式选择 推挽输出模式 高低电平都有驱动能力
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_12; //选择引脚
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; //引脚翻转速度选择
GPIO_Init(GPIOB,&GPIO_InitStructure);
while(1)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_12); //fmq 响
Delay_ms(100);
GPIO_SetBits(GPIOB,GPIO_Pin_12); //不响
Delay_ms(100);
GPIO_ResetBits(GPIOB,GPIO_Pin_12); //fmq 响
Delay_ms(100);
GPIO_SetBits(GPIOB,GPIO_Pin_12); //不响
Delay_ms(700);
}
}
蜂鸣器代码
最新推荐文章于 2025-04-11 10:17:54 发布