完整解决方案:STM32矩阵键盘程序4×4_计算机软件和应用_IT /计算机_信息

电脑杂谈  发布时间:2020-10-12 05:06:05  来源:网络整理

stm32矩阵键盘程序_stm32矩阵键盘程序_stm32 矩阵键盘 程序

/ * --------------------------------------------- ----------------------------------------- *矩阵键盘驱动程序*文件:键盘。 c *作者:LiuHui *说明:扫描4x4矩阵键盘输入,并返回键值*适用范围:该驱动程序用ST3.5库编写,适用于STM32F10x系列单片机*使用的引脚:PA0-PA7 *撰写时间:2014年5月20日------------------------------------------- --- ---------------------------------------- * / #include“ stm32f10x。 h“#包括” keyboard.h“ #include” dealy.h“ / * --------------------------------矩阵键盘初始化---------------------------------------- *功能:初始化stm32 MCU GPIO // PA0 -PA7 *参数传送:*输入:无*返回值:无-------------------------------- ------------------------------------------------- ----* / void KeyBoard_Init(void){GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure。

stm32 矩阵键盘 程序_stm32矩阵键盘程序_stm32矩阵键盘程序

GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3; GPIO_InitStructure。 GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure。 GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure。 GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure。 GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure。 GPIO_Mode = GPIO_Mode_IPD; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_SetBits(GPIOA,GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3); GPIO_Reset(GPIOA,GPIO_Pin_4 | GPIO_Pin_4 | GPIO1 ------------------------矩阵键盘scan ----------------------- --------------------- *功能:扫描矩阵键盘并返回键值*参数:*输入:无*返回:按下键以返回键值*当没有按键时,它返回0 --------------- -------------------------- ------------------------ --------------------- * / u8 Read_KeyValue(void){u8 KeyValue = 0; if(((GPIO_ReadInputData(GPIOA)&0xff)!= 0x0f){Delay_ms( 10); if((GPIO_ReadInputData(GPIOA)&0xff)!= 0x0f){GPIO_SetBits(GPIOA,GPIO_Pin_0); GPIO_ResetBits(GPIOA,GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3);开关(GPIO_ReadInputData(ffA)) case 0x11:KeyValue = 1; break; case 0x21:KeyValue = 5; break; case 0x41:KeyValue = 9; break; case 0x81:KeyValue = 13; break;} GPIO_SetBits(GPIOA,GPIO_Pin_1); GPIO_ResetBits(GPIOA, GPIO_Pin_0 | GPIO_Pin_2 | GPIO_Pin_3);开关(GPIO_ ReadInputData(GPIOA)&0xf f){case 0x12:KeyValue = 2;打破;情况0x22:KeyValue = 6;打破;情况0x42:KeyValue = 10; break;情况0x82:KeyValue = 14; break;} GPIO_SetBits(GPIOA,GPIO_Pin_2); GPIO_ResetBits(GPIOA,GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3); switch(GPIO_ReadInputData(GPIOA)&0xff){case 0x14; BreakValue; 3; case 0x24:KeyValue = 7; break; case 0x44:KeyValue = 11; break; case 0x84:KeyValue = 15; break;} GPIO_SetBits(GPIOA,GPIO_Pin_3); GPIO_ResetBits(GPIOA,GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2); switch(GPIO_ReadInputData(GPIOA)&0xff){case 0x18:case Value = 4; break;:KeyValue = 8; break; case 0x48:KeyValue = 12; break; case 0x88:KeyValue = 16; break;} GPIO_SetBits(GPIOA,GPIO_Pin_0 | | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3); GPIO_Reset_Bits(GPIOA,GPIO_Pin_4 | GPIO_Pin_4 | GPIO_Pin_4 | | GPIO_Pin_7); while(((GPIO_ReadInputData(GPIOA)&0xff);返回};值; 0};返回值) * - - - - - - - - - - - - - - - - -结束 - - - - - - - - -------------------- --------- * / / * -------- --------- ----------------------------------------- --------- ------------------- *矩阵键盘驱动程序* Fi le:键盘。

stm32矩阵键盘程序_stm32矩阵键盘程序_stm32 矩阵键盘 程序

h *作者:LiuHui *说明:扫描4x4矩阵键盘输入,并返回键值*适用范围:驱动器为ST3.5库编写,适用于STM32F10x系列单片机*使用的引脚:PA0-PA7 *撰写时间:2013年11月22日*版本:1.0 -------------------------------------- ------------------------------------------------ * / #ifndef __KEYBOARD_H#定义__KEYBOARD_H void KeyBoard_Init(void); u8 Read_KeyValue(void); #endif / * --------------------------- -------结束---------- --------------------------------*#include“ stm32f10x.h” void KeyBoard_Init(void){GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure。

stm32矩阵键盘程序_stm32矩阵键盘程序_stm32 矩阵键盘 程序

GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure。 GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure。 GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure。 GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure。 GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure。 GPIO_Mode = GPIO_Mode_IPD; GPIO_Init(GPIOB,&GPIO_InitStructure); GPIO_SetBits(GPIOB,GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6); GPIO_ResetBits(GPIOB,GPIO?GPIO_Pin_7 | GPIO_Pin_7 | GPIO_Pin_7 | GPIO?PA,PB void Delay_ms(int); {- {i = 12000; while(i--);}} u8 Read_KeyValue(void){u8 KeyValue = 1; if((GPIO_ReadInputData(GPIOB)&0xff)!= 0x0f){Delay_ms(10); if((GPIO_ReadInputData (GPIOB)&0xff)!= 0x0f){GPIO_SetBits(GPIOB,GPIO_Pin_3); GPIO_ResetBits(GPIOB,GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_5 | k13]; switch(GPIO_ReadInputData(GPIOB)&0xff); {case 7x11:情况0x21:KeyValue = 4;中断;情况0x41:KeyValue = 1;中断;情况0x81:KeyValue = 0;中断;} GPIO_SetBits(GPIOB,GPIO_Pin_4); GPIO_ResetBits(GPIOB,GPIO_Pin_3 | GPIO_Pin_5 | GPIO_Pin_6); switch(GPIO_ReadInputData(GPIOB)&0xff){case 0x12:KeyValue = 8; break; case 0x22:Key caseValue = 5; break;:KeyValue = 2; break; case 0x82:KeyValue = 0; break;} G PIO_SetBits(GPIOB, GPIO_Pin_5); GPIO_ResetBits(GPIOB,GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6); switch(GPIO_ReadInputData(GPIOB)&0xff){情况0x14:KeyValue = 9;打破;情况0x14:KeyValue = 9;打破;情况0x24:KeyValue = 9; 0x44:KeyValue = 3;打破;情况0x84:KeyValue = 0; GPIO_SetBits(GPIOB,GPIO_Pin_6); GPIO_ResetBits(GPIOB,GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5)); switch(GPIO_ReadInputData(ff)&0B)0x18:键值= 0;中断;情况0x28:键值= 0; case 0x48:KeyValue = 0; break; case 0x88:KeyValue = 0; break;} GPIO_SetBits(GPIOB,GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6); GPIO_ResetBits(GPIOB,GPIO_Pin_7 | GPIO_Pin_8; / while((GPIO_ReadInputData(GPIOB)&0xff)!= 0x0f); return KeyValue;}}返回0;} uint16_tEB表,0x28,0xB3,0xBA,0x78,0xDA,0xDB,0xA8,0xFB,0xFA}; int main() {RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); RCC_APB2PeriphClockCmd(RCH_GPIOA,ENABLE); RCC_APB2PeriphClockCmd(RCInvalue); KeyReadKey; Periph_GPIO; lue();] []; [[]; (i = 0; i


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/bofangqi/article-325493-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      • 梁李影
        梁李影

        桃子桃子桃子好帅这首歌我已经循环了无数遍了很喜欢桃子加油

      • 杞悼公成
        杞悼公成

        大陆一直在等机会

      • 霍利圣洁
        霍利圣洁

        你知道美国派多少

        • 卢宏涛
          卢宏涛

          在十二海里范围内布置水雷

      热点图片
      拼命载入中...