Arduino Voltage Average With Arrays

So I needed to make a program that would average four values that are present at the analog input.

This is what I came up with

Screenshot 2016-03-09 21.29.28

I wanted something that could easily scale if I wanted to sample more then twice and average the value, so that is why I did this with an array. When the code runs it samples the value at A0 four times and sticks that into the array, then it prints the values in the serial monitor. This is followed by the averageValue function that reads the values in the array adds them together and then divides the total.

Below is the file that has this Arduino code snippet, I hope to continue to develop more of these code snippets and upload them.

Average_With_Array

Leave a Reply

Your email address will not be published. Required fields are marked *