Pules Counter with Output 3V

Hi every one,

I need some help with a project.

We need to count the pulses from a flow sensor, which is working fine with the script we have but then we also need to send the same pulses out via another pin as the "pulse reader" we have has a threshold of 2.5V in order to "read" it as a pulse.

Can anyone help with the code so that the output pin provides a square wave that is 0V,when off and 3V when on? As this has to be exact and not just a rise or drop in voltage.

Thanks.

const int pulsePin = 2;
const int outPin = 13;

int pulseCounter = 0;
int pulseState = 0;
int lastPulseState = 0;

void setup()
{pinMode(pulsePin, INPUT);
pinMode(outPin, OUTPUT);
Serial.begin(9600);}

void loop() {

pulseState = digitalRead(pulsePin);

if (pulseState != lastPulseState) {
if (pulseState == HIGH) {

  pulseCounter++;
  Serial.println("HIGH");
  Serial.print("number of Pulses:  ");
  Serial.println(pulseCounter);
  digitalWrite(13, LOW);
} 
else {
  
  Serial.println("LOW");
  digitalWrite(13, HIGH); 
}

}

lastPulseState = pulseState;

}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

You don't say which board you are using, but generally if you want an accurate output level which isn't 5V or 3.3v (i.e. the supply volts) the best way to derive this is by external circuitry. Depending on the input impedance of your "pulse reader" this could be as simple as a voltage divider to reduce the 5v or 3.3 v at pin 13 to 3v.

Hi Jhaine, sorry I am using an Arduino Uno in this case. The flow sensor i am using is a Piusi K600/3 Pulser. The output voltage on the pin that it is currently on shows 5V on my multimeter but as soon as I start the flow on the se air it drops to a max of 1.4V and a min of 1.3V. Don’t know why this changes is happening…

That is happening because the multimeter is averaging the pulse on/off periods. You need a scope to see the pulses.

Please explain what device only accepts exact 3.0V pulses (your "pulse reader"). It is highly uncommon, so we would like to know why, and what it is.

Because, I doubt it.

How do you know that your "pulse reader" has a threshold of 2.5V? Please share the source of that information also.

Please also post a schematic of your current configuration.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.