I am a beginner programmer. I am making a little project where i read in a value from a 4x4 keypad and displaying the decimal value on the first line of the lcd and on the second line i need to show the binary value. I have already made the conversion from ASCII to DEC, but I cant display a value over 4 bits. For example if I want to show the number 75: when I press 7 , the decimal value and its binary code are being displayed. When i press 5 the display resets and the value 5 and its binary code are being displayed. I want to display 75 on the first line and on the second line the binary value of 75.
can someone help me with this problem?
here the code:
#include<Keypad.h>
#include <LiquidCrystal.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {7, 6, 5, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {3, 2, 1, 0}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
void setup() {
lcd.begin(16,2);
}
void loop() {
char key = keypad.getKey();
if (key != NO_KEY){;
lcd.setCursor(0,0);
lcd.print(key);
lcd.setCursor(0,1);
key=key-48;
lcd.print(key,BIN);
}
}