标题: STM32F103C8T6单片机键盘扫描测试程序 [打印本页]

作者: 254413002    时间: 2021-6-27 09:52
标题: STM32F103C8T6单片机键盘扫描测试程序
  1. #include "stm32f10x.h"
  2. //#include "led.h"
  3. #include "delay.h"
  4. #include "key.h"
  5. #include "sys.h"
  6. //#include "beep.h"
  7. #include "oled_iic.h"
  8. #include "display.h"
  9. //#include "24cxx.h"
  10. //#include "myiic.h"
  11. //#include "timer.h"
  12. //#include "as608.h"
  13. //#include "usart3.h"
  14. //#include "motor.h"
  15. #include "string.h"
  16. #include "stdio.h"

  17.       


  18. int main(void)
  19. {
  20.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
  21.         GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
  22.         vu8 key=0;
  23.         delay_init();
  24.         HZ= GB16_NUM();
  25.         OLED_Init();
  26.         KEY_Init();
  27.         char str[20];
  28.         OLED_Clear();
  29.   
  30.         while(1)
  31.         {
  32.                 key=KEY_Scan(0);
  33.                 if(key!=0)
  34.                 {
  35.                         sprintf(str,"key:%d",key);
  36.                         OLED_Clear();
  37.                         OLED_ShowCH(0,2,(u8*)str);
  38.                         delay_ms(1000);
  39.                         OLED_Clear();
  40.                         key=0;
  41.                 }
  42.                 else
  43.                 {
  44.                         OLED_ShowCH(0,2,"请按key");
  45.                 }
  46.         }
  47. }
复制代码

代码: 测试-键盘.7z (197.24 KB, 下载次数: 18)





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1