I have had this same problem too and I can t figure out how to fix it!
#include <LiquidCrystal.h>
#include <Keypad.h>
int opt1 = '+';
int opt2 = '+';
int find = 0;
int answer = 0;
char num[3];
int clear = 0;
int currentlength = 0;
int optlength = 0;
byte divide [8]={
0b00100,
0b00100,
0b00000,
0b11111,
0b11111,
0b00000,
0b00100,
0b00100,
};
const byte ROWS = 4;
const byte COLS = 4;
char Keys[ROWS][COLS] = {
{'1', '2', '3', '+'},
{'4', '5', '6', '-'},
{'7', '8', '9', 'x'},
{'*', '0', '=', 1}
};
byte rowPins[ROWS] = {5, A5, A4, A2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A1, A0, A3, A6};
Keypad keypad = Keypad(makeKeymap(Keys), rowPins, colPins, ROWS, COLS);
LiquidCrystal lcd(7,9,10,11,12,13); // the pins we use on the LCD
int P = 8;
void setup() {
digitalWrite(6, HIGH);
pinMode(6, OUTPUT);
lcd.createChar(1, divide);
lcd.begin(16, 2);
lcd.print("Type an equation");
lcd.setCursor(0,1);
lcd.cursor();
while(find==0){
while((optlength == 0)&&(currentlength == 0)&&(find == 0)){
char key = keypad.getKey();
key == NO_KEY;
if (key != NO_KEY){
if ((key != '+')&&(key != '-')&&(key != 'x')&&(key != 1)&&(key != '=')){
if(key == '*'){
digitalWrite(6, LOW);
}
if (key != '*'){
lcd.print(key);
num[0] = key;
currentlength++;
}
}
}
}
while((currentlength == 1)&&(optlength == 0)&&(find == 0)){
char optkey = keypad.getKey();
optkey == NO_KEY;
if ((optkey != NO_KEY)&&(optlength == 0)&&(currentlength == 1)){
if ((optkey == '+')||(optkey == '-')||(optkey == 'x')||
(optkey == 1)||(optkey == '=')||(optkey == '*')){
if(optkey == '*'){
digitalWrite(6, LOW);
}
if(optkey == '='){
lcd.print(optkey);
find++;
}
if((optkey != '=')&&(optkey != '*')){
lcd.print(optkey);
opt1 = optkey;
optlength++;
}
}
}
}
while((currentlength==1)&&(optlength==1)&&(find == 0)){
char key2 = keypad.getKey();
key2 == NO_KEY;
if ((key2 != NO_KEY)&&(currentlength == 1)){
if ((key2 != '+')&&(key2 != '-')&&(key2 != 'x')&&(key2 != 1)&&(key2 != '='))
{
if (key2 == '*'){
digitalWrite(6, LOW);
}
if (key2 != '*'){
lcd.print(key2);
num[1] = key2;
currentlength++;
}
}
}
}
while((currentlength == 2)&&(optlength == 1)&&(find == 0)){
char optkey2 = keypad.getKey();
optkey2 == NO_KEY;
if ((optkey2 != NO_KEY)&&(optlength == 1)&&(currentlength == 2)){
if ((optkey2 == '+')||(optkey2 == '-')||(optkey2 == 'x')||(optkey2 == 1)||
(optkey2 == '*')||(optkey2 == '=')){
if(optkey2 == '*'){
digitalWrite(6, LOW);
}
if(optkey2 == '='){
lcd.print(optkey2);
find++;
}
if((optkey2 != '=')&&(optkey2 != '*')){
lcd.print(optkey2);
opt2 = optkey2;
optlength++;
}
}
}
}
while((currentlength==2)&&(optlength==2)&&(find == 0)){
char key3 = keypad.getKey();
key3 == NO_KEY;
if ((key3 != NO_KEY)&&(currentlength == 2)){
if ((key3 != '+')&&(key3 != '-')&&(key3 != 'x')&&(key3 != 1)&&(key3 != '=')){
if (key3 == '*'){
digitalWrite(6, LOW);
if (key3 != '*'){
lcd.print(key3);
num[2] = key3;
currentlength++;
}
}
}
}
}
while((currentlength==3)&&(optlength==2)&&(find == 0)){
char findkey = keypad.getKey();
findkey == NO_KEY;
if(findkey != NO_KEY){
if((findkey == '=')||(findkey == '*')){
if (findkey == '*'){
digitalWrite(6, LOW);
}
if(findkey == '='){
find++;
}
}
}
}
}
}
void loop(){
}
My arduino can upload different code, but not this one, so I can't figure out what the problem is