#include <LiquidCrystal_I2C.h>
// (R & (1<<nieco)) ==1<<b
// PINB
boolean test1=false;
boolean test2=false;
int cislo=0;
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,20,4);
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.println("Zacni klikat (0-10)");
DDRB |=1<<3;
DDRB &=~(1<<0);
DDRB &=~(1<<1);
PORTB |=1<<0;
PORTB |=1<<1;
}
void loop() {
if((PINB&(1<<0)) !=0 && test1 != true){
test1=true;
}
if((PINB&(1<<0)) ==0 && test1 == true){
test1=false;
lcd.clear();
plus();
lcd.println(cislo);
}
if((PINB&(1<<1)) !=0 && test2 != true){
test2=true;
}
if((PINB&(1<<1)) ==0 && test2 == true){
test2=false;
lcd.clear();
minus();
lcd.println(cislo);
}
}
void plus(){
PORTB |=1<<0;
delay(2);
PORTB &=~(1<<0);
delay(2);
if(cislo<11){
cislo++;
Serial.println(cislo);
}
}
void minus(){
PORTB |=1<<1;
delay(2);
PORTB &=~(1<<1);
delay(2);
if(cislo>0){
cislo--;
Serial.println(cislo);
}
}