极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11205|回复: 1

有没谁有4*4键盘的程序,能在显示屏显示的 ?

[复制链接]
发表于 2017-3-30 17:03:17 | 显示全部楼层 |阅读模式
有没谁有4*4键盘的程序,能在显示屏显示的?
回复

使用道具 举报

发表于 2017-4-15 21:28:31 | 显示全部楼层
#include <Keypad.h>
//LingShun lab  
#include <Wire.h>   
#include <LiquidCrystal_I2C.h> //引用I2C库  
  
//设置LCD1602设备地址,这里的地址是0x3F,一般是0x20,或者0x27,具体看模块手册  
LiquidCrystal_I2C lcd(0x3F,16,2);   
  

  

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  lcd.init();                  // 初始化LCD  
  lcd.backlight();             //设置LCD背景等亮  
  Serial.begin(9600);
}
   
void loop(){
  char customKey = customKeypad.getKey();
   
  if (customKey){
    Serial.println(customKey);
    lcd.setCursor(0,0);                //设置显示指针  
  lcd.print(customKey);     //输出字符到LCD1602上  
  lcd.setCursor(9,1);  
  lcd.print(" Z.W.F.");  
   
   
   
  }
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-20 04:06 , Processed in 0.037119 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表