I am in the process of developing a 4-channel fan controller based upon using input from 4 temperature sensors. I have the single channel code working like a charm, however I am at a loss on how to smooth the input from 4 input channels, keep them seperate, and control 4 channels of output.
What changes do I need to make to make this code x4? I have been bashing my head against the desk for 3 days and can't seem to figure it out. Any help would be greatly appreciated.
const int numReadings = 5; // how many readings to average
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the averagevoid setup(){
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}void loop() {
total= total - readings[index]; // subtracts the last reading
readings[index] = analogRead(inputPin); // reads from the sensor
total= total + readings[index]; // adds the reading to the total
index = index + 1; // advance to the next position in the array
if (index >= numReadings) // if we're at the end of the array
index = 0; //wrap around to the beginning
average = total / numReadings; //Averages the readings
}