Assignment 1 – Smoothing



For the software, my main goal is to modulize the requests or organization for information into separate functions. One function receives the current value from the sensor. A second function calls the initial function, and places the value into an array for the number of times, variable sampleSize. A third function iterates through the array and returns the mean of all values. The different function can be called to view the sample value in an organized table.


//Ty Van de Zande
//Simple Data Average
static const int sampleSize = 160;
int readings[sampleSize];
int sampleIndex = 0;
void setup() {
void loop() {
// Averages samples array to output mean
int meanArray(){
int mean = buildArray();
mean = mean / sampleSize;
Serial.print("Mean: ");
return mean;
// Prints readings array in a nice format
void printArray(){
for(int i = 0; i<sampleSize; i++){
// Fills readings array with data from the sensor
int buildArray() {
int sum = 0;
for (int i = 0; i < sampleSize; i++){
readings[i] = straightData();
sum += readings[i];
return sum;
// Live feed of data from sensor
int straightData(){
int tempIn = analogRead(A6);
return tempIn;

Assignment 1: Basic Stats

Assignment 1: Basic Stats

Post Arduino sketch + Fritzing diagram to the blog by 23:59 Monday, 22 Jan 18.  No video or photos are needed, we’ll look at the sketches during the start of class.

Using two different analog sensors, read values and report on statistics. Do this over time, showing how collecting more analogRead() data in an array allows you to better refine the results for these operations
– mean
– median
– range, min and max values
– outlier (bonus points)
– standard deviation (bonus points)
– change sensor reading rate and sample size to change the interaction
More Bonus points! How can you take these results then modify your sketch to improve the results when it’s moved from one room to another? How can I decide between A10 or my house?