久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2397|回復: 0
打印 上一主題 下一主題
收起左側

KeyMatrix-Library (STM32F4)源碼

[復制鏈接]
跳轉到指定樓層
樓主
KeyMatrix Library (STM32F4)

Here is a library with which you can connect a keypad that is built as an X / Y matrix to the STM32F4.

It does not matter what the arrangement of the key matrix is (3 × 3, 4 × 3, 2 × 5, etc.).
No external diodes or pull-ups are needed.

In the H-file the size of the keyboard matrix is set (in the example 3 × 4)
and in the C-File the GPIO pins are assigned to the X and Y direction.

There is a function to read out the pressed key, which returns "0" if no key is pressed. If one or more keys are pressed, the key number of the first key found is returned. (In Example 1 to 12)

To debounce the buttons no timer but only a loop counter is used.
(this event needs to be adapted for you)

Note: if the return value is> 0 even if no keyboard is connected, external pull-ups (4k7) must be attached to the Y-lines.

Images :



//--------------------------------------------------------------
// File     : main.c
// Datum    : 02.05.2014
// Version  : 1.0
// Autor    : UB
// EMail    : mc-4u(@)t-online.de
// CPU      : STM32F4
// IDE      : CooCox CoIDE 1.7.4
// GCC      : 4.7 2012q4
// Module   : CMSIS_BOOT, M4_CMSIS_CORE
// Funktion : Demo der Key-Matrix-Library
// Hinweis  : Diese zwei Files muessen auf 8MHz stehen
//              "cmsis_boot/stm32f4xx.h"
//              "cmsis_boot/system_stm32f4xx.c"
//--------------------------------------------------------------

#include "main.h"
#include "stm32_ub_keymatrix.h"
#include "stm32_ub_led.h"

int main(void)
{
  uint8_t key_value;

  SystemInit(); // Quarz Einstellungen aktivieren

  // init der LEDs
  UB_Led_Init();

  // init der Tastatur-Matrix
  UB_KeyMatrix_Init();

  while(1)
  {
    // Tastatur-Matrix abfragen
    key_value=UB_KeyMatrix_Scan();
    // LEDs je nach Tasten-Nr schalten
    if(key_value==1) UB_Led_On(LED_GREEN); else UB_Led_Off(LED_GREEN);
    if(key_value==2) UB_Led_On(LED_RED); else UB_Led_Off(LED_RED);
    if(key_value==3) UB_Led_On(LED_BLUE); else UB_Led_Off(LED_BLUE);
    if(key_value==4) UB_Led_On(LED_ORANGE); else UB_Led_Off(LED_ORANGE);
  }
}

全部資料51hei下載地址:
Demo_83_KEY_Matrix.zip (173.43 KB, 下載次數: 12)


評分

參與人數 1黑幣 +100 收起 理由
admin + 100 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 欧美成人精品二区三区99精品 | 婷婷久久五月天 | 成人影 | 国产一区二区视频在线观看 | 毛片网站在线观看 | 超碰高清 | 欧美欧美欧美 | 99福利在线观看 | 天天看逼 | 久久久91 | 久久午夜国产精品www忘忧草 | 一区二区三区精品 | 欧美精品一区二区三区在线播放 | 国产日韩欧美激情 | 成人精品一区二区 | 亚州影院| 国产真实精品久久二三区 | 精品国产欧美一区二区 | 欧美成年网站 | 成人一级视频在线观看 | 一级久久久久久 | 午夜精品一区 | 欧美一区二区在线观看 | 久久精品com| 毛片久久久 | 日韩资源| 久久亚洲国产精品日日av夜夜 | 狠狠操在线 | 欧美日韩国产综合在线 | 天堂素人约啪 | 国产色婷婷久久99精品91 | 韩国久久 | 一区二区三区视频 | 欧美成人精品一区二区三区 | 亚洲一区二区三区在线播放 | 色综合色综合色综合 | 成人免费视频在线观看 | 亚洲免费视频在线观看 | 日韩视频精品在线 | 国产精品久久久久久久 | 一区二区av在线 |