Advertisement
RybaSG

Untitled

Sep 1st, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. // start, stop i reset stopera
  4. #define Start 8
  5. #define Stop 9
  6. #define Reset 10
  7.  
  8. LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
  9.  
  10. int seconds = 0;
  11.  
  12. void setup()
  13. {
  14.   pinMode(Start, INPUT_PULLUP);
  15.   pinMode(Stop, INPUT_PULLUP);
  16.   pinMode(Reset, INPUT_PULLUP);
  17.  
  18.   lcd.begin(16,2);
  19.   lcd.setCursor(0,0); // ustawienie kursora na poczatku pierwszej linii
  20.   lcd.print("Press Start");
  21. }
  22.  
  23. void loop()
  24. {
  25.    if(digitalRead(Start)==LOW)
  26.    {
  27.       while(1)
  28.       {
  29.           seconds++; // odliczanie sekund
  30.           delay(1000);
  31.           lcd.clear();
  32.           lcd.setCursor(0,0);
  33.           lcd.print("Press Stop");
  34.           lcd.setCursor(0,1);
  35.           lcd.print(seconds);
  36.     }
  37.    }
  38.          
  39.   if(digitalRead(Stop)==LOW) // zastopowanie licznika i pokazane sekundy
  40.     {      
  41.            lcd.clear();
  42.            lcd.setCursor(0,0);
  43.            lcd.print("Seconds :");
  44.            lcd.setCursor(10,0);
  45.            lcd.print(seconds);
  46.            lcd.setCursor(0,1);
  47.            lcd.print("Press Reset");
  48.     }  
  49.  
  50.   if(digitalRead(Reset)==LOW) // restart licznika
  51.    {
  52.     lcd.clear();
  53.     seconds = 0;
  54.     lcd.print("Press Start");
  55.     }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement