B
B
Bogdan B2017-03-17 23:26:23
Arduino
Bogdan B, 2017-03-17 23:26:23

How to start, stop and read values ​​from the system timer on Arduino?

Hello. There was a problem.
In general, there are 2 sensors, let's say an IR sensor.
And there is a task. Starting the timing at a high signal level on sensor 1 and stopping at a high signal level on sensor 2.
And one more task. If the signal level on one sensor is high, start the timer, if the signal level is high again (after a low one), stop the timer.
How to implement it correctly? Tell me please!
Sat dealt with timer interrupts, with this I more or less understood something. But I don’t understand how I can start the timer by interrupt or something like that.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kalapanga, 2017-03-18
@Booooooot

You don't need timer interrupts, but external interrupts and the millis() or micros() function. Here is almost exactly your case: Arduino Chronograph

A
Alexander Volkov, 2017-03-17
@a_volkov1987

You need to get two interrupts:
The first interrupt should be generated on the rising signal from sensor 1 (rising edge)
The second interrupt should be generated on the falling signal from sensor 2 (falling edge)
The first interrupt handler should issue a command to start the timer, and the second interrupt handler should to stop the timer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question