Answer the question
In order to leave comments, you need to log in
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
You don't need timer interrupts, but external interrupts and the millis() or micros() function. Here is almost exactly your case: Arduino Chronograph
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 questionAsk a Question
731 491 924 answers to any question