Advertisement
Guest User

Untitled

a guest
Oct 25th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <LiquidCrystal_I2C.h>
  2.  
  3. #include <Wire.h>
  4.  
  5.  
  6. int en = 2;
  7. int en1=4;
  8. int x;
  9. int wa;
  10. long licznik=0;
  11. long licznik2=0;
  12.  
  13. LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
  14.  
  15.  
  16. void setup() {
  17. lcd.begin(16,2);
  18. lcd.setCursor(0,0); // Ustawienie kursora w pozycji 0,0 (pierwszy wiersz, pierwsza kolumna)
  19.  
  20. pinMode(en, INPUT);
  21. pinMode(en1, INPUT);
  22. attachInterrupt(digitalPinToInterrupt(2), onStep, FALLING);
  23.  
  24.  
  25.  
  26. }
  27.  
  28. // the loop function runs over and over again forever
  29. void loop() {
  30. lcd.setCursor(0,0);
  31. lcd.print(" ");
  32. lcd.setCursor(0,0);
  33. lcd.print(licznik);
  34.  
  35.  
  36.  
  37. }
  38.  
  39.  
  40. void onStep()
  41. {
  42. x = digitalRead(en1);
  43. if(x==1)
  44. licznik++;
  45. else
  46. licznik--;
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement