Hi, i'm new here and i need some help to find out my problem.
I try to average data from my ultrasonic sensor, but i don't understand how to do it.
Please help me to finish it, thank you and this is my code for my ultrasonic sensor.
Do you want a rolling average, so an updated average for every sample period, or do you want to wait for 300 samples, and just get one average every 300 sample periods?
AWOL:
Do you want a rolling average, so an updated average for every sample period, or do you want to wait for 300 samples, and just get one average every 300 sample periods?
That's it, i just want one average every 300 sample periods.
Simplest way is to set up a for loop.
Before the for loop, set a sum variable (a long, probably) to zero, then iterate through the for loop 300 times, summing the echo pulse durations into the long variable.
At the end, divide the sum by 300, and convert to the units of your choice.
Don't take readings too quickly - not more than about twenty or thirty a second.
Take the numbers 5,6, and 7 and apply that math to those numbers. I use just one box to represent numbers going into the same cell as well as represent what you have coded.
Take the numbers 5,6, and 7 and apply that math to those numbers. I use just one box to represent numbers going into the same cell as well as represent what you have coded.
i'm try to compile data from HC-SR04 until 50/100 data and average it, and i don't know how to compile the data and average it. Not spesific numbering like that you give to me.