Подключение клавиатуры к Ардуино
Рассмотрим как можно подключить клавиатуру к Arduino
Используем LCD дисплей для отображения вводимой информации
Область применения может быть огромна, начиная от пианино до кодового замка
Ниже приведен скетч, на основе которого можно создать любую клавиатуру
Код:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
const byte rows = 4;
const byte cols = 5;
char keys[rows][cols] = {
{'7','8','9','>','C'},
{'4','5','6','=','/'},
{'1','2','3','x',':'},
{'0',',','F','F','-'}
};
byte rowPins[rows] = {11,10,9,8}; // пины Arduino
byte colPins[cols] = {7,6,5,4,3}; // пины Arduino
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
void setup()
{
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("You Pressed:");
}
void loop()
{
char key = keypad.getKey();
if (int(key) != 0) {
lcd.setCursor(16,1);
lcd.print(key);
}
}