基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx

上传人:b****1 文档编号:577565 上传时间:2022-10-11 格式:DOCX 页数:20 大小:18.13KB
下载 相关 举报
基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx_第1页
第1页 / 共20页
基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx_第2页
第2页 / 共20页
基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx_第3页
第3页 / 共20页
基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx_第4页
第4页 / 共20页
基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx

《基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx》由会员分享,可在线阅读,更多相关《基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx(20页珍藏版)》请在冰豆网上搜索。

基于stm32的LCD12864显示+16个矩阵键盘程序文件.docx

基于stm32的LCD12864显示+16个矩阵键盘程序文件

#include"stm32f10x.h"

#defineread_busybit()GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_7)

#defineDATAOUTGPIOC->ODR//

unsignedchartable1[]={"65"};

unsignedchartable2[]={"大学"};

unsignedchartable3[]={"学院"};

unsignedchartable4[]={"电子信息"};

unsignedchartable5[]={"姓名"};

unsignedcharhy5;

unsignedchark=0;

voiddelay(unsignedintx)

{

while(x--);

}

 

//外设时钟使能

 

/*************************************************************************/

voidRCC_Configuration(void)//在208页这里是引脚时钟配置

{

/*使能外设时钟*/

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|

RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|

RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE,ENABLE);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);

}

/*******************************************************************************

全部用到1602的引脚将在在配置

*******************************************************************************/

voidGPIO_Configuration(void)//1602引脚配置

{

GPIO_InitTypeDefGPIO_InitStructure;

/*LD1&LD2&LD3&LD4configration*/

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOE,&GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOA,&GPIO_InitStructure);

//矩阵键盘引脚输出配置

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_9;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOB,&GPIO_InitStructure);

//矩阵键盘引脚输入配置

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13|GPIO_Pin_11|GPIO_Pin_7|GPIO_Pin_6;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOB,&GPIO_InitStructure);

}

voidkey()//按键检测

{

unsignedcharii,jj;

unsignedintkey[10][10];

u16ling[]={GPIO_Pin_7,GPIO_Pin_6,GPIO_Pin_11,GPIO_Pin_13};

u16heng[]={GPIO_Pin_0,GPIO_Pin_1,GPIO_Pin_2,GPIO_Pin_9};

GPIO_SetBits(GPIOB,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_9);

for(ii=0;ii<4;ii++)

{

GPIO_ResetBits(GPIOB,heng[ii]);

for(jj=0;jj<4;jj++)

{

delay(50000);

delay(50000);

//delay(50000);

if(GPIO_ReadInputDataBit(GPIOB,ling[jj])==0)

{

while(GPIO_ReadInputDataBit(GPIOB,ling[jj]==0));

key[ii][jj]=1;

}

else

{

key[ii][jj]=0;

//delay(50000);

}

}

GPIO_SetBits(GPIOB,heng[ii]);

}

if((key[0][0]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[0])==1)){hy5=1;}//****

if((key[0][1]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[0])==1)){hy5=2;}

if((key[0][2]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[0])==1)){hy5=3;}

if((key[0][3]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[0])==1)){hy5=4;}

if((key[1][0]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[1])==1)){hy5=5;}//***

if((key[1][1]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[1])==1)){hy5=6;}

if((key[1][2]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[1])==1)){hy5=7;}

if((key[1][3]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[1])==1)){hy5=8;}

if((key[2][0]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[2])==1)){hy5=9;}//*****

if((key[2][1]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[2])==1)){hy5=10;}

if((key[2][2]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[2])==1)){hy5=11;}

if((key[2][3]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[2])==1)){hy5=12;}

if((key[3][0]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[3])==1)){hy5=13;}//*****

if((key[3][1]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[3])==1)){hy5=14;}

if((key[3][2]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[3])==1)){hy5=15;}

if((key[3][3]==1)&&(GPIO_ReadInputDataBit(GPIOB,ling[3])==1)){hy5=16;}

//hy2=9;

//returnhy2;

//

}

voidLCD_DataIo_In(void)//数据线输入1602输入引脚配置

{

GPIO_InitTypeDefGPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOE,&GPIO_InitStructure);

}

voidLCD_DataIo_Out(void)//数据线输出1602引脚输出配置

{

GPIO_InitTypeDefGPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOE,&GPIO_InitStructure);

}

voidhy()

{

GPIO_ResetBits(GPIOE,GPIO_Pin_7);

GPIO_ResetBits(GPIOE,GPIO_Pin_6);

GPIO_ResetBits(GPIOE,GPIO_Pin_5);

GPIO_ResetBits(GPIOE,GPIO_Pin_4);

GPIO_ResetBits(GPIOE,GPIO_Pin_3);

GPIO_ResetBits(GPIOE,GPIO_Pin_2);

GPIO_ResetBi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1