Implementarea acestui proiect necesita urmatoarele componente:
-Arduino Board(in cazul meu Arduino UNO);
-tastatura numerica (4x3 keypad);
-Modul LCD controlat de un microcontroller HD44780A00 sau echivalent(interfata de comunicatie este de tip paralel);
-rezistente;
-3x push-buttons;
Celor interesati de realizarea acestui proiect le pot oferi toate indicatiile si materialele de care au nevoie(codul sursa si eventual conexiunile daca imaginile de mai jos nu ofera o foarte buna intelegere).
Cateva demonstratii:
CODUL SURSA:
#include <Keypad.h>
#include <LiquidCrystal.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {4, 3, 2, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5}; //connect to the column pinouts of the keypad
const int butonScadere=16;
const int butonInmultire=17;
const int butonImpartire=18;
const int butonRadical=19;
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
unsigned int numar1=0, numar2=0;
boolean nr1citit=false,opAdunare=false, opScadere=false, opInmultire=false, opImpartire=false;
void setup(){
pinMode(butonScadere,INPUT);
pinMode(butonInmultire,INPUT);
pinMode(butonImpartire,INPUT);
pinMode(butonRadical,INPUT);
Serial.begin(9600);
lcd.begin(24, 2);
lcd.print("calculator improvizat");
}
void loop(){
char key = keypad.getKey();
if(key){
if((key !='*')&&(key !='#')){
if(!nr1citit){
numar1=(numar1*10)+int(key-'0');
lcd.setCursor(0,1);
lcd.print(numar1);
}
else if(nr1citit){
numar2=(numar2*10)+int(key-'0');
lcd.setCursor(8,1);
lcd.print(numar2);
}
}
else if(key=='*'){
lcd.setCursor(6,1);
lcd.print("+");
nr1citit=true;
opAdunare=true;
}
else if(key=='#'){
lcd.setCursor(13,1);
lcd.print("=");
if(opAdunare){
double suma=numar1+numar2;
lcd.setCursor(15,1);
lcd.print(suma);
delay(10000);
}
else if(opScadere){
double dif=numar1-numar2;
lcd.setCursor(15,1);
lcd.print(dif);
delay(10000);
}
else if(opInmultire){
double prod=numar1*numar2;
lcd.setCursor(15,1);
lcd.print(prod);
delay(10000);
}
else if(opImpartire){
double cat=numar1/numar2;
lcd.setCursor(15,1);
lcd.print(cat);
delay(10000);
}
lcd.setCursor(0,1);
lcd.print(" ");
numar1=numar2=0;
nr1citit=false;
opAdunare=opScadere=opInmultire=opImpartire=false;
}
}
else if (digitalRead(butonScadere)){
lcd.setCursor(6,1);
lcd.print("-");
nr1citit=true;
opScadere=true;
}
else if (digitalRead(butonInmultire)){
lcd.setCursor(6,1);
lcd.print("*");
nr1citit=true;
opInmultire=true;
}
else if (digitalRead(butonImpartire)){
lcd.setCursor(6,1);
lcd.print(":");
nr1citit=true;
opImpartire=true;
}
}