Implementare
Codul foloseste un singur firmware - Arduino Nano - ce realizeaza comunicarea dintre componente si calculeaza rezultatul dorit.
Biblioteci
#include <Arduino.h> #include <LiquidCrystal_I2C.h> #include <Keypad.h> #include "TimerOne.h" #include "EasyBuzzer.h"
Tastatura
1 | 2 | 3 | D |
4 | 5 | 6 | x |
7 | 8 | 9 | y |
C | 0 | . | = |
Functionalitati:
const byte ROWS = 4; //four rows const byte COLS = 4; //four columns //define the characters on the buttons of the keypad char keys[ROWS][COLS] = { {'1','2','3','D'}, {'4','5','6','x'}, {'7','8','9','y'}, {'C','0','.','='} }; byte rowPins[ROWS] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad // Create the Keypad object Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
Ecran
// set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2);
Variabile globale
char prev; // previous character bool point = false; // check if there is a point in the number char op[50]; // the operation char rez[50]; // the result int mode = 0; // mode of operation char x = '+'; // first operator char y = '-'; // second operator int ct = 0; // character count int intrerupere = 0; // active/inactive interrupt
Structuri
typedef struct cor { char x; double y; } __attribute__((packed)) char_double;
Functii