Posts Tagged ‘function’


Handy Function

November 5, 2015

A while back I wrote this handy function for Arduino called rolling average.  This is a good function to have when working with sensors from a weather station.

It could easily be adapted to have an array with 24 objects in it to average something like light levels or sunshine over a day.  To do this I would change  int sensorReadings[10]; to int sensorReadings[24]; and long interval = 2000; to long interval = 3600000;.  This way it updates once an hour for 24 hours.

I find using a light sensor is an easy to test that it works correctly.

I set it up like this –

Read the rest of this entry ?