Hey all.
I'm trying to write a program based on Arduino Uno that will allow me to take one of three actions depending on the average input from a vehicle ride height sensor over a period of time.
Being a ride height sensor, there will always be minor noise as roads are not perfectly level. In addition, there will be occasional larger spikes as the car goes over bigger bumps or corners.
The program needs to find the center of this data, and establish whether the car is riding too high, too low, or within the correct range, and take one of three actions based on this for a few seconds, before starting the process over again.
I looked into moving averages, but it seems like it would make things much simpler if I just gather data for a minute, calculate an average, take an action, and then start the loop over again. Constant adjustments are not needed, there shouldn't be much variation in the ride height from one minute to the next. Whether mean or median is better for this, I'm not sure.
All I've found so far are sketches for moving averages, how would one take a series of, say, 60 values, average this, take an action, and then start all over again, dumping all previous data?