LCD keypad shield для Arduino (без LCD дисплея!)

LCD keypad shield для Arduino (без LCD дисплея!)

Артикул:  301rd
230 грн.
Наличие: нет в наличии
Модель: DFR0009-BP
+
LCD keypad shield для Arduino (без самого LCD дисплея!)

Шилд позволяет разместить LCD дисплей (например 16x2 совместимый дисплей). Этот шилд использует Arudino LCD4Bit библиотеки.
Имеет 5 программируемых кнопок и 1 кнопку сброса
Не совместим с 20-контактным разъемом ЖК-дисплея.

Pin-фунуции
Analog 0 Button (select, up, right, down and left)
Digital 4 DB4
Digital 5 DB5
Digital 6 DB6
Digital 7 DB7
Digital 8 RS (Data or Signal Display Selection)
Digital 9 Enable
Digital 10 Backlit Control


Пример программного кода
Example use of LCD4Bit_mod library
LCD4Bit_mod Library Download
//
#include
//create object to control an LCD.
//number of lines in display=1
LCD4Bit_mod lcd = LCD4Bit_mod(2);
//Key message
char msgs[5][15] = {"Right Key OK ",
"Up Key OK ",
"Down Key OK ",
"Left Key OK ",
"Select Key OK" };
int adc_key_val[5] ={30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;
void setup() {
pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat

lcd.init();
//optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
//lcd.commandWrite(0x0F);//cursor on, display on, blink on. (nasty!)
lcd.clear();
lcd.printIn("KEYPAD testing... pressing");
}
void loop()
{
adc_key_in = analogRead(0); // read the value from the sensor
digitalWrite(13, HIGH);
key = get_key(adc_key_in); // convert into key press
if (key != oldkey) // if keypress is detected
{
delay(50); // wait for debounce time
adc_key_in = analogRead(0); // read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key != oldkey)
{
oldkey = key;
if (key >=0){
lcd.cursorTo(2, 0); //line=2, x=0
lcd.printIn(msgs[key]);
}
}
}
digitalWrite(13, LOW);
}
// Convert ADC value to key number
int get_key(unsigned int input)
{ int k;
for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
{ return k; }
}
if (k >= NUM_KEYS)
k = -1; // No valid key pressed
return k;
}
Example use of LiquidCrystal library
//Sample using LiquidCrystal library
#include

/*******************************************************


********************************************************/

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5

// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
return btnNONE; // when all others fail, return this...
}

void setup()
{
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Push the buttons"); // print a simple message
}

void loop()
{
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up


lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
lcd.print("RIGHT ");
break;
}
case btnLEFT:
{
lcd.print("LEFT ");
break;
}
case btnUP:
{
lcd.print("UP ");
break;
}
case btnDOWN:
{
lcd.print("DOWN ");
break;
}
case btnSELECT:
{
lcd.print("SELECT");
break;
}
case btnNONE:
{
lcd.print("NONE ");
break;
}
}

}

Техническое состояние : новый
Гарантия:  2 месяца