Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal_I2C.h>
- #include <Wire.h>
- int en = 2;
- int en1=4;
- int x;
- int wa;
- long licznik=0;
- long licznik2=0;
- LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
- void setup() {
- lcd.begin(16,2);
- lcd.setCursor(0,0); // Ustawienie kursora w pozycji 0,0 (pierwszy wiersz, pierwsza kolumna)
- pinMode(en, INPUT);
- pinMode(en1, INPUT);
- attachInterrupt(digitalPinToInterrupt(2), onStep, FALLING);
- }
- // the loop function runs over and over again forever
- void loop() {
- lcd.setCursor(0,0);
- lcd.print(" ");
- lcd.setCursor(0,0);
- lcd.print(licznik);
- }
- void onStep()
- {
- x = digitalRead(en1);
- if(x==1)
- licznik++;
- else
- licznik--;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement