Advertisement
elektronek

Lukas Moravek - pocitadlo

Feb 28th, 2022
1,471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal_I2C.h>
  2. LiquidCrystal_I2C lcd(0x27, 16, 2);
  3.  
  4. #define INTERRUPT_INPUT 2
  5.  
  6. volatile int pulse_counter = 0;
  7. int pom_counter = -1; // Jen skrz prvni vypis nuly
  8.  
  9. void interrupt_handler()
  10. {
  11.   pulse_counter++;
  12. }
  13.  
  14. void setup()
  15. {
  16.   lcd.init();
  17.   lcd.backlight();
  18.   pinMode(INTERRUPT_INPUT, INPUT_PULLUP);
  19.   attachInterrupt(digitalPinToInterrupt(INTERRUPT_INPUT),interrupt_handler, FALLING);
  20. }
  21.  
  22. void loop(){
  23.   if (pom_counter!=pulse_counter)
  24.   {
  25.     lcd.print("PICKUP Winder");
  26.     lcd.setCursor(5,1);
  27.     lcd.print(pulse_counter);
  28.     lcd.setCursor(11,1);
  29.     lcd.print("winds");
  30.     pom_counter=pulse_counter;
  31.  }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement