Pulse counter

any one know how to build a simple pulse counter that counts all the highs and refreshes when a high is sent thrue a diffrent pin.

Hello.

Use a microcontroller with a timer/counter that can count from an input pin. You didn’t specify how you want to read the resulting count out, but a microcontroller will give you plenty of options there with minimal work.

- Jan

I am also interesting in a pulse counter, or Pulse Timer.
a routine that meausures the ms between PIN HIGH, and PIN LOW every 20ms between 1ms - 2ms.
In my case I am sending a signal to PC3(signal in to Baby-O), and black to ground.
I am controling the baby-O with my rc-radio channel 6(switch).

when the switch is at 0 degrees this should read 1.0ms pulse.
when the switch is at 90 degrees this should read 1.5ms pulse.
when the switch is at 180 degrees this should read 2.0ms pulse.

how would one express this in terms of “C” programing.
Timer0 and Timer2 are being used for motor functions, if you have a timer example
Timer1 would be best.

while(1) // loop forever
{
delay_ms(20) // wait 20ms before measureing pulse
PINread=0
while (PINread<2)
{
if (PC3 is HIGH)
{
settimer1
PINread++;
}
if (PC3 is LOW)
{
PINread++;
TimeInMS = readtimer1
if (TimeInMS = ValueNeeded)
do some function
}
}

I have the basic concept but I need help filling in some detail

**How to && || bits to achieve bit reading/writing ect …
**How to sync with the receivers 20ms count. the receiver sends the pulses every 20ms
**How to make sure there is an accurate reading.
**How to make sure HIGH is read and then LOW is read before cycling into another 20ms delay

please advise