void loop()
{
val = analogRead(analogPin); // read the input pin
for(y=0;y<300;y++) {
val=val+analogRead(analogPin);
}
;
Serial.println(val); // debug value
delay (500);
}
Why do I get a negative value in this loop? If I write 200 instead of 300 I get positive values. There’s no reason for me to get a negative value as analogRead(analogPin) is always positive. My objective is to meke an average of the readings but these negative values are ruining my program…