kopiere Sketch hierher damit Sie den Beitrag als Lösung markieren können.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); // addresse 0x3F schreiben wenn mit 0x27 nicht klappt
#include <Keypad.h>
char H[3];
char L[3];
const byte KEYPAD_ROWS = 4;
const byte KEYPAD_COLS = 4;
byte rowPins[KEYPAD_ROWS] = {5, 4, 3, 2};
byte colPins[KEYPAD_COLS] = {A3, A2, A1, A0};
char keys[KEYPAD_ROWS][KEYPAD_COLS] = {
{'0', '1', '2', '3'},
{'4', '5', '6', '7'},
{'8', '9', 'A', 'B'},
{'C', 'D', 'E', 'F'}
};
Keypad keypad(makeKeymap(keys), rowPins, colPins, KEYPAD_ROWS, KEYPAD_COLS);
void setup() {
lcd.init();
lcd.clear();
lcd.setCursor(0, 0); lcd.print("FEDC BA98 7654 3210");
lcd.setCursor(0, 01); lcd.print("0000 0000 0000 0000");
}
void loop() {
static uint16_t Total = 0;
char key = keypad.getKey();
if (key) {
if (key > '9')key -= 7;
key -= '0';
Total = Total ^ (1 << key);
lcd.setCursor(0, 1);
for (byte i = 16; i > 0; i--) {
lcd.print(Total & 1 << i-1?'1':'0');
if (i % 4 == 1)lcd.print(' ');
}
sprintf (H, "%02X", Total >> 8);
sprintf (L, "%02X", Total & 0xFF);
lcd.setCursor(7, 2);
lcd.print(H);
lcd.setCursor(17, 2);
lcd.print(L);
lcd.setCursor(12, 3);
lcd.print(" ");
lcd.setCursor(12, 3);
lcd.print(Total);
key=0;
delay(100);
}
}