arduino uno
Mi problema es que tengo un proyecto de llenado de un bote de 1lt y el CAUDALIMETRO YF-S201, no se activa quisiera saber cual es el problema. Ya que lo quiero activar mediante un teclado 4x4 , hace la secuencia si se activa el motor pero no se ve el conteo de los pulsos en el lcd ..solo se queda asi:
Espere..
Cargando:0.00L
#include<Wire.h>
#include<Keypad_I2C.h>
#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const byte Filas = 4;
const byte Columnas = 4;
char Teclado [Filas][Columnas]=
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte PinesFilas[Filas] ={0,1,2,3};
byte PinesColumnas[Columnas] = {4,5,6,7};
int dir_teclado = 0x20;
Keypad_I2C kpd = Keypad_I2C(maKeymap(Teclado), PinesFilas, PinesColumnas, Filas, Columnas, dir_teclado);
//varibles
int pulso;
int numPulsos = 0;
int boton = 3;
int dato;
int estado;
char tecla;
const int bomba1 = 11;
volatile double waterFlow;
boolean state = false;
void setup()
{
kpd.begin();
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("cargando");
delay(1000);
waterFlow=0;
estado=0;
lcd.clear();
menuP();
pinMode(boton, INPUT);
pinMode(bomba1, OUTPUT);
attachInterrup(0, pulse,RISING);
digitalWrite(bomba1, HIGH);
}
void loop()
{
pulso = digitalRead(boton);
if(pulso == 0 && estado ==0)
{
numPulsos++;
lcd.clear();
lcd.setCursor(3,0);
lcd.print("pulso");
lcd.print(numPulsos);
delay(100);
lcd.setCursor(3,1);
lcd.print("total:10");
}
if(numPulsos == 10)
{
lcd.clear();
lcd.setCursor(2,0);
lcd.print("presiona -A-");
lcd.setCursor(2,1);
lcd.print("para llenado"); .........numPulsos = 0;
estado = 1;
}
tecla = kpd.getKey();
if(tecla)
{
if(tecla =='A' && estado == 1)
{
lcd.clear();
digitalWrite(bomba1, LOW);
state=true;
waterFlow=0;
}
if(state == true)
{
lcd.setCursor(0,0);
lcd.print("espere");
lcd.setCursor(0,1);
lcd.print("cargando:");
lcd.print(waterFlow);
lcd.print("L");
delay(100);
}
if(waterFlow >= 1)
{
lcd.clear();
digitalWrite(bomba1, HIGH);
lcd.setCursor(1,0);
lcd.print("litro completo");
delay(200);
lcd.clear();
state = false;
waterFlow = 0;
menuP();
}
}
------funciones-------
void pulse()
{
waterFlow += 1.0 / 450.0;
}
void menuP()
{
lcd.setCursor(0,0);
lcd.print("presiona btn");
}