Advertisement
RuiViana

Vazao.ino

Oct 28th, 2020 (edited)
2,427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3.  
  4. double calculoVazao;
  5. volatile int contador;
  6. float fluxoAcumulado =0;
  7. float metroCubico = 0;
  8. float ContaAgua = 0;
  9.  
  10.  
  11. LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);
  12.  
  13.  
  14.  
  15. void setup() {
  16.  
  17.   lcd.begin(16,2);
  18.  
  19.   pinMode(2,INPUT);
  20.   attachInterrupt(0,Vazao,RISING);
  21.   Serial.begin(9600);
  22.  
  23.  
  24.  
  25.  
  26. }
  27.  
  28.  
  29.  
  30. void loop() {
  31.   contador = 0;
  32. //  interrupts();
  33.   delay(1000);
  34. //  noInterrupts();
  35.  
  36.  
  37.   calculoVazao= (contador * 2.25);
  38.   fluxoAcumulado = fluxoAcumulado + (calculoVazao / 1000);
  39.   metroCubico = fluxoAcumulado / 1000;
  40.   ContaAgua = metroCubico * 3,59;
  41.   calculoVazao = calculoVazao * 60;
  42.   calculoVazao = calculoVazao / 1000;
  43.  
  44.  
  45.  
  46.  
  47.   Serial.println("Litros por minuto : ");
  48.   Serial.println(calculoVazao);
  49.   Serial.println("Gasto total L :");
  50.   Serial.println(fluxoAcumulado);
  51.   Serial.println("Metros cubicos totais : ");
  52.   Serial.println(metroCubico);
  53.   Serial.println("R$ : ");
  54.   Serial.println(ContaAgua);
  55.  
  56. // lcd.init();
  57.  lcd.backlight();
  58. // lcd.clear();
  59.  lcd.setCursor(0,0);
  60.  lcd.print("Litros p/m");
  61.  lcd.print(calculoVazao);
  62.  
  63.  
  64. }
  65.  
  66.  
  67.  
  68. void Vazao()
  69. {
  70.   contador ++;
  71.  
  72.  
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement