Danke fuer die Antwort.
ich verwende die Beispiel so wie sie angegen sind.
Der Code fuer den Arduino lautet:
/*
Sainsmart LCD Shield for Arduino
Key Grab v0.2
Written by jacky
www.sainsmart.com
Displays the currently pressed key on the LCD screen.
Key Codes (in left-to-right order):
None - 0
Select - 1
Left - 2
Up - 3
Down - 4
Right - 5
*/
#include <LiquidCrystal.h>
#include <DFR_Key.h>
//Pin assignments for SainSmart LCD Keypad Shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
//---------------------------------------------
DFR_Key keypad;
int localKey = 0;
String keyString = "";
void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Key Grab v0.2");
delay(2500);
/*
OPTIONAL
keypad.setRate(x);
Sets the sample rate at once every x milliseconds.
Default: 10ms
*/
keypad.setRate(10);
}
void loop()
{
/*
keypad.getKey();
Grabs the current key.
Returns a non-zero integer corresponding to the pressed key,
OR
Returns 0 for no keys pressed,
OR
Returns -1 (sample wait) when no key is available to be sampled.
*/
localKey = keypad.getKey();
if (localKey != SAMPLE_WAIT)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Current Key:");
lcd.setCursor(0, 1);
lcd.print(localKey);
}
}
Die Folder fuer DFR_Key sind auch angelegt.
KR