Hey.
I need some help on how i shall beging the code for an easy calculator that can do +, - , *, /.
That will show result in serial monitor.
The code I have now:
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3','+'},
{'4','5','6','-'},
{'7','8','9','/'},
{'C','0','=','*'}
};
byte rowPins[ROWS] = {7, 6, 5, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {12, 11, 10, 9}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
//float a = key;
//float b = key;
//float h;
void setup(){
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();
if (key != NO_KEY){
Serial.print(key);
}
}
The thing is that i i do not know how i shall shall continue.
Need help with following things:
- code for assigning variables so that i can have use bigger numbers then 9( eg.342 = num1) like store them or something.
- code so i can take the two diffrent numbers i have put in diffrent variables with the Keypad(eg. 123+45)
- code so i can press = and get result
- code so i can press c to begin on a new row
Did read something about using FunctionDeclaration but don't get how to use it with keypad.lib.
I'm really new to this but think i can solve it if i atleast can get an exemple of how it would work with addition.
And to thoose i think goggle it. I have and when i find something it is to complex or they don't how code or they use and lcd screen.
Thx for help