Average Three Sensor Values
This example uses the Math block to calculate the average of three numeric sensor readings.
Required blocks
- Three sensor or device blocks with numeric outputs
- Math
- An optional block that stores or displays the result
Program flow
Sensors a, b and c → Math → Average value
Configuration
- Add the three sensor sources and a Math block to the workspace.
- Use the + control on the Math block to add input
c. - Connect the three sensor values to inputs
a,bandc. - Enter
(a + b + c) / 3in the F(x) field. - Connect the
F(x)output to the block that should use the average.
Example calculation
For the readings 21, 22 and 23, the formula calculates:
(21 + 22 + 23) / 3 = 22
Result
Whenever one of the sensor readings changes, the Math block recalculates the average and passes the new value to its output.