Average
The AVERAGE command is useful if you want to look at the changes on a sensor over a longer period of time. For example taking a reading of sound levels during the night could be done by storing the sound level every five minutes, but this will only store the volume at the precise moment the reading is taken. By averaging the readings for every five minute period a better impression of the sound levels during the night will be built up. An example procedure using the AVERAGE command is shown in fig. 13.

How it works. The first line of this procedure opens file 1 for storage and gives it the filename "data". The next line sets up a loop which will be completed 100 times. Line three clears the value of average to begin a new set of samples. Line four starts a loop which averages the reading from sensor A over 10 readings, taking a reading once every second. The average value is then stored and the program returns to line two to complete the next sample. Once 100 readings have been stored the disk file is closed.