#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,16,2);
bool test1 = true;
bool test2 = true;
int ktore = 0;
int min = 0;
int sek = 0;
void setup()
{
lcd.init();
lcd.backlight();
DDRD &= ~(1<<7);
DDRD &= ~(1<<6);
PORTD |= 1<<7;
PORTD |= 1<<6;
}
void loop()
{
if(sek == 60){
min++;
sek = 0;
vypis();
}
if((PIND&(1<<7)) == 0 && test1 == true){
if(ktore){
min++;
vypis();
}
else{
sek++;
vypis();
}
test1 = false;
}
if((PIND&(1<<6)) == 0 && test2 == true){
if(ktore){
ktore = 0;
vypis();
}
else{
ktore = 1;
vypis();
}
test2 = false;
}
if((PIND&(1<<7)) != 0 && test1 == false){
test1 = true;
}
if((PIND&(1<<6)) != 0 && test2 == false){
test2 = true;
}
}
void vypis(){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(String(min) + ":" + String(sek));
if(ktore){
lcd.setCursor(0,1);
lcd.print("min");
}
else{
lcd.setCursor(0,1);
lcd.print("sek");
}
}