#include <LiquidCrystal.h>
#define Set1(R,b) R|=1<<b
#define Set0(R,b) R&=~(1<<b)
#define Get(R,b) (R&(1<<b))
LiquidCrystal lcd(13,12,11,10,9,8);
bool button = true;
volatile int col = 0;
char currentChar[] = {'A','B','C'};
void setup() {
lcd.begin(16,2);
PORTD |= 0b00011100;
EIMSK |= (1<<0);//Set1(EIMSK,INT0);
EICRA |= (1<<0); //Set1(EICRA,ISC00);
EICRA |= (1<<1); //Set0(EICRA,ISC01);
EIMSK |= (1<<1); //Set1(EIMSK,INT1);
EICRA |= (1<<2); //Set1(EICRA,ISC10);
EICRA |= (1<<3); //Set0(EICRA,ISC11);
Set1(SREG,7);
}
void loop() {
if(Get(PIND,4) == 0 && button){
lcd.setCursor(0,1);
lcd.print("Volba:");
lcd.setCursor(7,1);
lcd.print(currentChar[col]);
button = false;
}else if(Get(PIND,4) != 0 && !button){
button = true;
}
if(col == 0){
lcd.setCursor(0,0);
lcd.print("A b c");
}else if(col == 1){
lcd.setCursor(0,0);
lcd.print("a B c");
}else if(col == 2){
lcd.setCursor(0,0);
lcd.print("a b C");
}
}
ISR(INT0_vect)
{
if(col < 2)
col++;
else
col = 0;
}
ISR(INT1_vect){
if(col > 0)
col--;
else
col = 2;
}