#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int minuty = 0;
int sekundy = 0;
int ktore = 0; // 0=m 1=s
bool test1 = true;
bool test2 = true;
void setup()
{
DDRB &= ~(1<<1);
PORTB |= 1<<1;
DDRB &= ~(1<<0);
PORTB |= 1<<0;
lcd.init();
lcd.backlight();
lcd.print(String(minuty) + ":" + String(sekundy));
lcd.setCursor(0, 1);
lcd.print("min");
}
void loop()
{
if( (PINB&(1<<0)) == 0 && test1 == true )
{
test1 = false;
if(ktore == 0) // zmena na prvom riadku
{
minuty++;
lcd.home();
lcd.print(String(minuty) + ":" + String(sekundy));
}
else
{
sekundy++;
lcd.home();
lcd.print(String(minuty) + ":" + String(sekundy));
}
}
if( (PINB&(1<<0)) != 0 && test1 != true )
{
test1 = true;
}
if( (PINB&(1<<1)) == 0 && test2 == true ) // prepnutie druhého riadku
{
test2 = false;
if(ktore == 0)
{
ktore = 1;
lcd.setCursor(0, 1);
lcd.print("sek");
}
else
{
ktore = 0;
lcd.setCursor(0, 1);
lcd.print("min");
}
}
if( (PINB&(1<<1)) != 0 && test2 != true )
{
test2 = true;
}
}