多彩编程 多彩编程MZPH · CODE BLOG
ARTICLE DETAIL

文章详情

深耕前端与后端开发技术的一线实战笔记与踩坑复盘。

day4 蜂鸣器

day4 蜂鸣器 #include stm32f10x.h // Device header #include Delay.h int main(void){ FunctionalState a; a ENABLE; a DISABLE; a (FunctionalState) 0; //外设时钟控制函数 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); Delay_ms(500); GPIO_SetBits(GPIOB,GPIO_Pin_12); Delay_ms(500); GPIO_ResetBits(GPIOB,GPIO_Pin_12); Delay_ms(500); GPIO_SetBits(GPIOB,GPIO_Pin_12); Delay_ms(500); GPIO_ResetBits(GPIOB,GPIO_Pin_12); Delay_ms(500); GPIO_SetBits(GPIOB,GPIO_Pin_12); Delay_ms(500); } }
返回列表