Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- // Tvuj LCD
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27,16,2);
- // Muj LCD
- // #include <LiquidCrystal_PCF8574.h>
- // LiquidCrystal_PCF8574 lcd(0x27);
- #define startbutt 2
- #define minusbutt 0 // Nedavej to na piny 0 a 1 - tam je USART
- #define plusbutt 1 // a uz si ni cnevypises na Serial pripadne
- #define piezo 3
- #define redC 13
- #define blueC 12
- #define greenC 11
- int Sec = 0; // Sekundy staci
- int zobrazit=1; // rezim zobrazeni
- int stisknutoP=0; // priznak stisku PLUS
- int stisknutoM=0; // priznak stisku MINUS
- char buffer[20]; // Pomocny buffer pro displej - sprintf format
- void setup()
- {
- pinMode(startbutt, INPUT_PULLUP);
- pinMode(minusbutt, INPUT_PULLUP);
- pinMode(plusbutt, INPUT_PULLUP);
- // Init Tveho LCD
- lcd.init();
- lcd.backlight();
- // Init meho LCD
- // lcd.begin(16,2);
- // lcd.setBacklight(255);
- lcd.setCursor(0,0);
- lcd.print("digital exposure");
- delay(1);
- lcd.setCursor(0,1);
- lcd.print("unit 1.0");
- delay(10);
- analogWrite(redC, 255);
- tone(piezo,350,800);
- delay(4500);
- }
- void zobraz()
- {
- zobrazit=0;
- sprintf(buffer,"Time %02d:%02d",Sec/60, Sec%60);
- lcd.setCursor(0,1);
- lcd.print(buffer);
- }
- void loop()
- {
- if (zobrazit) zobraz();
- if (digitalRead(plusbutt)==0 && stisknutoP==0)
- {
- stisknutoP=1;
- Sec++;
- zobrazit=1;
- delay(20);
- }
- if (digitalRead(plusbutt)) { delay(20); stisknutoP=0;}
- if (digitalRead(minusbutt)==0 && Sec > 0 && stisknutoM==0)
- {
- stisknutoM=1;
- Sec--;
- zobrazit=1;
- delay(20);
- }
- if (digitalRead(minusbutt)) {delay(20); stisknutoM=0;}
- // a sem si doplnis funkce dalsiho tlacitka nebo co je potreba a pokud je potreba aktualizovat vypis
- // na displej tak staci nastavit promennou zobrazit=1; a je to :-)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement