flowmeter and pulseIn()?Help!

I use the code like this:
#include<stdio.h>
#include<stdlib.h>
#include <floatToString.h>
#include <LCD4Bit.h>
LCD4Bit lcd = LCD4Bit(2);
char flow[6];//dispaly char
int flowrate =4;
unsigned long duration;
void setup() {
lcd.init();
pinMode(flowrate, INPUT);
Serial.begin(9600);
}
void loop() {
//read pulse****************
duration = pulseIn(flowrate, HIGH);//read flow meter
Serial.println(duration);
lcd.clear();
//flowrate -display
lcd.cursorTo(1, 0);// line=2,x=0

lcd.printIn(“Frate:”);
floatToString(flow,duration ,1,7,false);
lcd.printIn(flow);
}

but as the quantity of flowmeter is increased,the frequence of output pluse is increased also,and my LCD will be twinkled,and serial monitor refresh rate is incread also and I can not see clear the LCD’s content (there are some number!)…but how this happend…anyone can give some advice?thanks… :slight_smile:

Lose the LCD4bit library. The Official LiquidCrystal library now works fine with 4 bit LCDs, is much faster and has less issues. The code not being able to keep up is probably much of your problem. The official Library will certainly help.

Hi thanks pluggy! I use offical code,it seems better compared with 4bitLCD.h.but new quesstion 1)the pluse out put of flowmeter range from 36~916Hz,can pluseIn() captured the range correctly and have accurent enough,or in the other word arduino can cope the frequence range? 2)I use code : lcd.setCursor(0, 1); duration = pulseIn(flowrate, HIGH);//read flow meter // duration=(((1/duration)-3.66)/366.69)+0.1; (if I compute this,I can not see anything in my LCD,but if Ilet flometer working there are some text ,and WHY????) floatToString(flow,duration ,1,7,false); lcd.print(flow); anyone can help me ?,thanks very mauch!!!

flowmeter pulse outputs are generally "open collector" which means you either need an external pull up resistor to +5, or you could turn on the internal pullups with this generic code ( you already have a pinMode cmd )

pinMode(pin, INPUT); // set pin to input digitalWrite(pin, HIGH); // turn on pullup resistors

the internal pullups are 20K, I'd use something between 5K to 10K for an external pull up.