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屏幕介绍
OLED可作为调试的工具,其他调试方式如下:
2.硬件电路
左为四针脚版,右为七针脚版
3.驱动函数(仅适合这里使用的OLED驱动代码:资料下载)
4.线路链接
代码:
在第一行第一列显示字符A
#include "stm32f10x.h" // Device header
#include "OLED.h"
int main(void)
{
OLED_Init();
OLED_ShowChar(1,1,'A');
while(1)
{
}
}