4 CHANNEL (LM35 PWM) FAN CONTROLLER QUESTION

Here is the correct code:

Many things can be improved...and there is one bug

The bug is that (on a UNO or similar) an int cannot store the sum of 100x a value that can go up to 1023... use unsigned long to accumulate the readings. Note that You don’t need to read analog entry 100x to be stable - reading twice should be enough unless your temperature varies hyper quickly within a few milliseconds (in which case you should lower the duration of the delay)

Your delay(1000); would fit better at the very end of the loop

pins are best defined as const byte rather than int.

Your PC is fast, there is no need to go slow on Serial, use Serial.begin(115200); instead of 9600 and of course set the serial console at 115200 bauds in the pop up

Give meaningful names to your variable and write appropriate comments

Your code repeats 4 times something similar. Using arrays and a for loop would make your code smaller

=======

Also Please correct your posts above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)