Hey guys, im trying to figure out how to take an average of 10 readings every second and to put out that average reading into serial print for a duration of 5 minutes for both heating and cooling.
Can you guys help write a code for me, I just dont know what to do. Do i put in another for loop inside the for loop of 300?
Heres the code I have so far:
void setup()
{
pinMode(2, OUTPUT); // sets the digital
Serial.begin(9600);
delay(500);
}
void loop()
{
int adin;
float tpc, tpf;
Serial.println("Heater On");
digitalWrite(2, HIGH); // turns the LED on
for(int i=1; i<=300; i++)
{
adin=analogRead(0);
tpc=adin*.4888;
tpf=tpc*1.8+32.;
Serial.println(i);
Serial.println(tpf);
delay(2000);
}
Serial.println("Heater Off");
digitalWrite(2, LOW); // turns the LED off
for(int i=1; i<=300; i++)
{
adin=analogRead(0);
tpc=adin*.4888;
tpf=tpc*1.8+32.;
Serial.println(i);
Serial.println(tpf);
delay(2000);
}
}