I usually program VHDL in FPGAs, so im not too familiar with MCUs.
i thought i might give Arduino a try this time. Any help would be much appreciated.
i would like to measure the speed of a moving object.
the set up is going to be 2 optical sensors. and 2 laser pointers.
this will create 2 beams.
as the object pass, it will break the first beam. then the second.
the time taken to break the beams, will be stored.
with the known distance, and the measured time, the speed of the object can be calculated.
my questions are:
- how do i make a counter to measure the time taken to break beam1 and beam2?
- do i simply make a “if-statement”, and a “count++” to measure the number of clock cycles?
how do i detect “rising_edge” or “falling_edge” of beam1 and beam2?
i cannot really use this because i am reading the sensors from the ADC.
sadly this cannot be changed because i need an adjustable threshold.
is it possible to store, letsay, 10 measurements in an array.
attached is a diagram of the set up.
any links to sample codes, or a description will be much appreciated. thanks.