Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #define CLK 52
- #define DT 50
- #define SW 48
- LiquidCrystal_I2C lcd(0x27,20,4);
- int counter = 0;
- int state;
- int lastState;
- int volba;
- void setup()
- {
- Serial.begin(9600);
- lcd.init();
- lcd.backlight();
- Serial.begin(9600);
- pinMode(CLK,INPUT);
- pinMode(DT,INPUT);
- pinMode(SW,INPUT);
- Serial.begin(9600);
- lastState = digitalRead(CLK);
- }
- void loop() {
- state = digitalRead(CLK);
- if(state != lastState)
- {
- if(digitalRead(DT) != state)
- {
- counter++;
- }
- else
- {
- counter--;
- }
- lcd.clear();
- lcd.setCursor(0,1);
- lcd.print("Pozice: ");
- lcd.print(counter);
- Serial.print(counter);
- Serial.println();
- if(counter<0){
- counter=5;}
- if(counter>=6){
- counter=0;}
- if(counter==0 or counter==1){
- lcd.clear();
- lcd.setCursor(2,0);
- lcd.print("Zvolte napoj");
- lcd.setCursor(5,1);
- lcd.print("Jahoda");}
- if(counter==2 or counter==3){
- lcd.clear();
- lcd.setCursor(2,0);
- lcd.print("Zvolte napoj");
- lcd.setCursor(5,1);
- lcd.print("Malina");}
- if(counter==4 or counter==5){
- lcd.clear();
- lcd.setCursor(2,0);
- lcd.print("Zvolte napoj");
- lcd.setCursor(4,1);
- lcd.print("Boruvka");}
- }
- if(digitalRead(SW) != 1)
- {
- volba++;
- counter=0;
- }
- lastState= state;
- }
- if(volba==1 and counter==0 or volba==1 and counter==1)
- {
- lcd.clear();
- lcd.setCursor(4,0)
- lcd.print("Zvolte silu");
- lcd.setCursor(1,5)
- lcd.print("-");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement