How can i calculate the time delay in arduino?

• salaheddine
In summary, a student is working on a project to calculate the speed of waves in liquid using two piezoelectric elements as a transmitter and receiver. They are trying to determine the time between sending and receiving a signal and are unsure if they need to protect the elements from short circuiting. They may also need to use doppler frequency shift for more accurate results and could seek help on an Arduino forum.

salaheddine

hi every one , I'm a student in university , i have a projet it's about calculate speed of waves in liquid by to piezo electrique , one workd like emmeter and the other receppter , the distance betwin the two piezo is fixe , the probleme is i nedd to calculat the time betwin the moment who i send the signal and when i received ? and i want to know if it's ok to put piezo disque in liquide or i need to protecte theme by somthing to avoid court circuit ?
thinx

Last edited by a moderator:
Welcome to PF.

I think you can get better answers by posting your question on one of the Arundino forums.

salaheddine said:
one workd like emmeter and the other receppter
salaheddine said:
i nedd to calculat the time betwin the moment who i send the signal and when i received ?
I guess those two instants are detected by the hardware using signals produced by the piezoelectric sensors? To compute the time elapsed between these two events, you can use millis() or micros() functions which read the on-board timer and give output in ms or μs.

You might need to coat the elements with lacquer or a very thin layer of epoxy to prevent damage to the metallisation. Are you studying surface waves? Can you draw a diagram of your transmitter and receiver location relative to the surface and waves. You may be able to use doppler frequency shift rather than a simple pulse.

anorlunda said:
Welcome to PF.

I think you can get better answers by posting your question on one of the Arundino forums.
thanks you

1. How do I calculate the time delay in Arduino?

To calculate the time delay in Arduino, you need to determine the length of time you want the delay to be and multiply it by the clock speed of the Arduino. For example, if you want a delay of 1 second and your Arduino has a clock speed of 16 MHz, the calculation would be 1 second x 16,000,000 cycles per second = 16,000,000 cycles.

2. What is the clock speed of Arduino?

The clock speed of Arduino varies depending on the model, but most Arduino boards have a clock speed of 16 MHz. However, some newer models, such as the Arduino Due, have a clock speed of 84 MHz.

3. Can I use the delay() function to calculate time delay in Arduino?

Yes, the delay() function in Arduino is commonly used to create time delays. However, it is important to note that the delay() function is not precise and may vary depending on the other processes running on the Arduino board. For more precise time delays, it is recommended to use the millis() function.

4. How do I use the millis() function to calculate time delay in Arduino?

To use the millis() function in Arduino, you need to first declare a variable to store the current time, and then use a conditional statement to compare the current time with the desired delay time. For example, if you want a delay of 1 second, you would declare a variable to store the current time and then use an if statement that checks if the current time is greater than or equal to the desired delay time plus the initial time.

5. Are there any other ways to calculate time delay in Arduino?

Yes, there are other ways to calculate time delay in Arduino, such as using the micros() function or implementing a timer interrupt. These methods may offer more precise timing, but they require a deeper understanding of Arduino programming. It is recommended to start with the delay() and millis() functions before exploring other methods of calculating time delay in Arduino.