#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define BTN1 4
#define BTN2 3
#define BTN3 2
float curensy = 0.0;
float result = 0.0;
int choice = 0;
const float USD = 41.38;
const float EUR = 47;
const float PLN = 11;
void setup() {
lcd.init();
lcd.clear();
lcd.backlight();
pinMode(BTN1, INPUT_PULLUP);
pinMode(BTN2, INPUT_PULLUP);
pinMode(BTN3, INPUT_PULLUP);
}
void loop() {
if(digitalRead(BTN1)==LOW){
delay(10);
curensy = curensy + 1.1;
lcd.setCursor(0,0);
lcd.print(String(curensy) + " UAH");
}
if(digitalRead(BTN2)==LOW){
delay(200);
choice = choice + 1;
if(choice == 1) {
lcd.setCursor(0,1);
result = curensy / USD;
lcd.print("-> USD");
}
if(choice == 2) {
lcd.setCursor(0,1);
lcd.print("-> EUR");
result = curensy / EUR;
}
if(choice == 3) {
lcd.setCursor(0,1);
lcd.print( "-> PLN");
result = curensy / PLN;
}
if(choice > 3) {
lcd.setCursor(0,1);
choice = 0;
}
}
if(digitalRead(BTN3)==LOW){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Result: ");
lcd.setCursor(0,1);
lcd.print(result);
}
}