Pulse counter


How to count the pulses varying between 2V and 1.5V?
I have counted the pulses varyng between 2.5V and 0V. But I am not able to count the pulses varying between 2V and 1.5V as electric imp is not detecting those pulses properly. It is not having any timer so that I can compare the pulse with the reference value defined by me and increment the counter (variable to count) by one for each pulse and measure the no. of pulses in a specific amount of time.
Please help me.

You should use a comparator (an op-amp will basically work the same way).

Power it off 3.3v.
On the + input feed your pulse in.
On the - input put a resistor divider set to be 1.75v (essentially no current goes into an op-amp input so you can use say, 270k from - to ground and 240k from - to 3.3v)
Output of the opamp goes to the imp pin.

When the + input is greater than the - input, you will see 3.3v on the imp pin. When + is less than -, 0v.

Thanks a lot Hugo.

Hi, you could also use pin.configure(ANALOG_IN) and monitor the pulses for the desired voltage. This only if the pulses are long enough to register.

Thanks ssylca. I will try that too. Thank you for helping me.