Hi Friends,
I am making a Calculator with a Arduino Nano ,16x2 LCD Display ,4x4 Matrix Keypad.
It has the following features:
- It accepts two numbers and performs + or - or * or /
- It has a Reset button, a Enter button and a Clear button[Reset and Clear are connected to A0 and A1 due to lack of Digital Pins]
- It powers an LCD Display which displays your actions with the Calculator
I'll take care of the Reset button and Clear button, I need help for the rest of the project and code.
I created a code (I'll ask for any doubts in the loop later)
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,0);
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS]={
{'1','2','3','+'},
{'4','5','6','-'},
{'7','8','9','*'},
{'.','0','E','/'}
};
byte rowPins[ROWS]={13,10,9,8};
byte colPins[COLS]={7,6,2,1};
double ans;
Keypad matrix = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup()
{
lcd.begin(16,2);
lcd.clear();
}
void inputnum1()
{
lcd.print("First Number:");
lcd.setCursor(0,1);
char num1 = matrix.getKey();
if (num1)
{
lcd.print(num1);
}
if (num1=E)
{
lcd.clear();
inputnum1;
}
}
void inputnum2()
{
lcd.print("Second Number:");
lcd.setCursor(0,1);
char num2 = matrix.getKey();
if (num2)
{
lcd.print(num2);
}
if (num2=E)
{
lcd.clear();
inputnum2;
}
}
void inputop()
{
lcd.print("Select Operation:");
lcd.setCursor(0,1);
char op = matrix.getKey();
if (op==(+))
{
lcd.print("Addition");
}
if (op==(-))
{
lcd.print("Substraction");
}
if (op==(*))
{
lcd.print("Multiplication");
}
if (op==(/))
{
lcd.print("Division");
}
}
void loop()
{
inputnum1;
//....Contd
}
But it shows a list of errors
Arduino: 1.6.6 (Windows 7), Board: "Arduino Nano, ATmega328"
C:\Users\DEVANAND\Documents\Arduino\Calculator\Calculator.ino: In function 'void inputnum1()':
Calculator:53: error: 'E' was not declared in this scope
if (num1=E)
^
C:\Users\DEVANAND\Documents\Arduino\Calculator\Calculator.ino: In function 'void inputnum2()':
Calculator:71: error: 'E' was not declared in this scope
if (num2=E)
^
C:\Users\DEVANAND\Documents\Arduino\Calculator\Calculator.ino: In function 'void inputop()':
Calculator:85: error: expected primary-expression before ')' token
if (op==(+))
^
Calculator:90: error: expected primary-expression before ')' token
if (op==(-))
^
Calculator:95: error: expected primary-expression before ')' token
if (op==(*))
^
Calculator:100: error: expected primary-expression before '/' token
if (op==(/))
^
Calculator:100: error: expected primary-expression before ')' token
if (op==(/))
^
exit status 1
'E' was not declared in this scopeThis report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
What do I do for this ?
Please help me out by posting a proper code....