Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- double calculoVazao;
- volatile int contador;
- float fluxoAcumulado =0;
- float metroCubico = 0;
- float ContaAgua = 0;
- LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);
- void setup() {
- lcd.begin(16,2);
- pinMode(2,INPUT);
- attachInterrupt(0,Vazao,RISING);
- Serial.begin(9600);
- }
- void loop() {
- contador = 0;
- // interrupts();
- delay(1000);
- // noInterrupts();
- calculoVazao= (contador * 2.25);
- fluxoAcumulado = fluxoAcumulado + (calculoVazao / 1000);
- metroCubico = fluxoAcumulado / 1000;
- ContaAgua = metroCubico * 3,59;
- calculoVazao = calculoVazao * 60;
- calculoVazao = calculoVazao / 1000;
- Serial.println("Litros por minuto : ");
- Serial.println(calculoVazao);
- Serial.println("Gasto total L :");
- Serial.println(fluxoAcumulado);
- Serial.println("Metros cubicos totais : ");
- Serial.println(metroCubico);
- Serial.println("R$ : ");
- Serial.println(ContaAgua);
- // lcd.init();
- lcd.backlight();
- // lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Litros p/m");
- lcd.print(calculoVazao);
- }
- void Vazao()
- {
- contador ++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement