Hello!
Here is my schematics attached.
I have a fan controlled by LM35DZ and a pot for controlling a led dimmer.
Here is I have a code:
void setup()
{
TCCR0A = 2<<COM0A0 | 3<<WGM00; // clear 0c0a at compare match //enable fast pwm
TCCR0B = 1<<CS00;
}
void loop() {
analogWrite(0, map(analogRead(3), 0, 1023, 0, 72));
int t = analogRead(2)/2;
if (t>80) {
int value = (t-80)+55;
analogWrite( 1, value);
delay(100);
}
else {
analogWrite( 1, 0);
}
}
LM35 works fine when the pot stays at the position 0 and the fan starts just when the temperature becomes the one when the fan has to start. As soon as I start rotating the pot the voltage on LM35 also changes and goes higher, and it starts the fan. How can I eliminate this interference? I’ve tried to add delay or dummies to give the Tiny’s ADC time to recover, but it hasn’t helped.