I have 2 ultrasonic sensors hooked up to an arduino in parallel, these 2 sensors are supposed to give me the distance of an object which passes them. Right now I am getting 2 readings for distances, which is what I want, but I also want the serial monitor to print the time between 'sensor 1' picking up a valid reading, and 'sensor 2' picking up a reading (the time it takes for the object to travel between the 2 sensors).
I have a real time clock just in case it is required.
Secondly, can anyone help edit my code so the serial monitor only gives me readings if it is within my required distance range, instead of just printing 'out of range' as its currently programmed to do so?
If I were looking for help on a project, I would be making things as easy as possible for those I seek help from.
Like posting my efforts in an easily accessible format.
bajwz:
Secondly, can anyone help edit my code so the serial monitor only gives me readings if it is within my required distance range, instead of just printing 'out of range' as its currently programmed to do so?
bajwz:
Secondly, can anyone help edit my code so the serial monitor only gives me readings if it is within my required distance range, instead of just printing 'out of range' as its currently programmed to do so?
Assuming your "required distance range" is between 30 and 250 it is programmed to do just that.
How is an ultrasonic sensor measuring a distance "an event"? When you can answer that, recording when that event occurs is trivial. When both events have happened, you can easily calculate the interval.