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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2467|回復: 0
收起左側(cè)

KeyMatrix-Library (STM32F4)源碼

[復制鏈接]
ID:263845 發(fā)表于 2017-12-19 19:16 | 顯示全部樓層 |閱讀模式
KeyMatrix Library (STM32F4)
blogmedia-keypad-schematic-gif.gif
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, 下載次數(shù): 12)


評分

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

查看全部評分

回復

使用道具 舉報

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

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产在线中文字幕 | 午夜免费视频观看 | 国产精品福利视频 | 欧美日韩在线一区二区 | 91婷婷韩国欧美一区二区 | 国产精品嫩草影院精东 | 亚洲第一区久久 | 美女久久视频 | 亚洲国产精品久久久久婷婷老年 | 91免费福利在线 | 国内精品视频在线 | 91精品国产一区二区三区 | 羞羞在线观看视频 | 韩国理论电影在线 | 国产精品视频二区三区 | 日韩一区在线观看视频 | 精品日韩一区二区 | 99精品久久久| 国产探花在线观看视频 | 免费观看一级毛片 | 在线亚洲一区 | 成人欧美一区二区三区在线观看 | 欧美激情一区二区三区 | 一级片av| 色毛片 | 黄色一级大片在线免费看产 | 玖玖免费 | 91爱啪啪 | 欧美激情在线播放 | 9久久婷婷国产综合精品性色 | 日日骚网 | 久久99精品久久久水蜜桃 | 免费观看羞羞视频网站 | 国产在线一区二区三区 | 欧美国产一区二区三区 | 欧美三级成人理伦 | 亚洲综合在线视频 | 在线成人www免费观看视频 | 超碰91在线| av手机在线 | 日韩在线精品强乱中文字幕 |