Reading Timer 1 count with change on one pin only

A Good morning to the forum.

I have just started with Arduino UNO after using PIC MCU's and PicBasic Pro for nearly 20 years. What a positive surprise at my age to be able to write in C, allthough most of my sketches are from existing efforts by other Arduiners, with only minor adaptation by me. I am learning, I am hooked!

My Objective : To change my existing PIC ballistic chronograph to Arduino UNO operation, using a single pin to start/stop a timer.

My detector consists of a start sensor and a stop sensor which operates a flip/flop circuit. The pulse from the flip/flop is the length of the time it takes for the bullet to move between start/stop sensors. On the PIC MCU I am using the Capture mode pin, using the rising edge to start a timer which is 'ticked" by the oscillator to give 1 micro second ticks. The falling edge of the capture mode pin is used to read the value of the timer. Calculation and reporting is done via LCD.

My question : Does the Arduino have a similar capture pin ? I have been studying a lot of timer and frequency counter sketches, but I was unable to find the answer. I would seem that I will have to address the specific registers directly, but I am unsure.

Thank you in advance.

Danie Joubert - George

Forum roup,

Just after posting this I have come across Nick's frequency sketch, using one pin. Nick I will have a look at that. Sorry for the inconvenience.

Timer 1 has in input Capture Register (ICR) which can catch the value of Timer 1 on the edge of an input pulse. I think there is also an ICR interrupt so when the first value is captured you can save it and set up for the second capture.

johnwasser: Timer 1 has in input Capture Register (ICR) which can catch the value of Timer 1 on the edge of an input pulse. I think there is also an ICR interrupt so when the first value is captured you can save it and set up for the second capture.

Yes, this is the best way I know. There is a catch: it can detect either falling or rising edge, not both. So you set it to wait for rising edge, when interrupt comes save ICR and switch to falling edge. When another interrupt comes you get result and switch back to rising edge. Look to the datasheet for more information. On Arduino Uno it is Digital 8 (PB0/ICP1 on ATMega).

Hi group,

A big thank you to the 2 replies on my question. (Smajdalf & johnwasser) I am at the moment studying the data sheet around ICR. Thanks for pointing out the switching back to prepare for second pulse.

By using ICR I can discard my flip/flop circuit and feed my start and stop signals straight to ICR pin.

I am hooked on Arduino but still lots to learn.