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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 2500|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

KeyMatrix-Library (STM32F4)源碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:263845 發(fā)表于 2017-12-19 19:16 | 只看該作者 |只看大圖 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
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, 下載次數(shù): 12)


評(píng)分

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

查看全部評(píng)分

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

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 免费一区二区视频 | 91亚洲国产成人久久精品网站 | 天天躁日日躁bbbbb | 欧美成人xxx | 五月天激情综合网 | 日日夜夜精品免费 | 丁香六月婷婷 | 久草青青草 | 欧美日韩国产一区 | 中文字幕精品三区 | 欧美又粗又长 | 日韩五十路 | 国产成人亚洲精品自产在线 | 黄色小说视频网站 | 久久在线免费视频 | 99在线免费观看视频 | 91av在线看| 亚洲成人日韩 | 91人人爽 | 三级在线观看视频 | 天天草天天干 | 日韩视频在线免费观看 | 黄色网址在线播放 | 精品日韩在线 | 久久久久a | 欧美日韩在线免费观看 | 一区二区视频在线 | 国产一区欧美 | 欧美福利一区 | 国产成人免费在线视频 | 天天操天天干天天 | av日韩在线播放 | 青青草福利视频 | 亚洲影视在线 | 成 人 黄 色 片 在线播放 | 中文字幕有码在线 | 欧美日韩专区 | 成人毛片网站 | 人人草人人爽 | 国产一区二区av | 精品一区视频 |