Hey,
I have a problem with this Led keypad shield not working (sort of). It works with an Arduino Uno but not with an Arduino Mega 2560 (even though it connects with both boards the same way).On the mega the display doesn't light up and the buttons don't work (except for the reset button). The documentation says that it should work with an Arduino Uno or a similar microcontroller, and I consider the Mega 2560 a similar microcontroller. This is the code for it: explanation is inside of the code
#include <LedKeypad.h>
char brightness = 0;
char buf[5] = "2020";
void setup() {
ledkeypad.begin(); /*Enable*/
ledkeypad.setBrightness(0);/*Sets the brightness level*/
ledkeypad.display(0000);/*Display data*/
delay(1000);
ledkeypad.display(buf);/*Display character for testing*/
for (int i = 0; i < 4; i++) { /*for testing*/
ledkeypad.dotShow(i);
delay(200);
ledkeypad.dotVanish(i);
}
}
void loop() {
unsigned char keyValue = 0;
keyValue = ledkeypad.getKey();/*Get key value*/
switch (keyValue) {
case KEY_DOWN:
buf[0]++;
if (buf[0] > '9')
buf[0] = '0';
ledkeypad.display(0, buf[0]); // add 1 to the first character
break;
case KEY_LEFT:
buf[1]++;
if (buf[1] > '9')
buf[1] = '0';
ledkeypad.display(1, buf[1]); // add 1 to the second character
break;
case KEY_UP:
buf[2]++;
if (buf[2] > '9')
buf[2] = '0';
ledkeypad.display(2, buf[2]); // add 1 to the third character
break;
case KEY_RIGHT:
buf[3]++;
if (buf[3] > '9')
buf[3] = '0';
ledkeypad.display(3, buf[3]); // add 1 to the fourth character
break;
case KEY_SELECT:
brightness++;
if (brightness > 7)
brightness = 0;
ledkeypad.setBrightness(brightness); // make display brighter by 1
break;
default:
break;
}
}