1.蜂鸣器的使用
先看接线图
第一步:使用rcc开启GPIO时钟
第二步:初始化GPIO(这里选择的是pb12)
第三步:使用输出函数控制GPIO
代码如下
#include "stm32f10x.h" // Device header
#include "Delay.h"
int main(void)
{
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB,ENABLE);
GPIO_InitTypeDef GPIOInint;
GPIOInint.GPIO_Mode=GPIO_Mode_Out_PP;
GPIOInint.GPIO_Pin=GPIO_Pin_12;
GPIOInint.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIOInint);
while(1)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_12);
Delay_ms(500);
GPIO_SetBits(GPIOB,GPIO_Pin_12);
Delay_ms(500);
}
}
2.oled屏幕
1:OLED屏幕介绍