Go Down

Topic: 1 photoresistor 2 leds (sorry for my english) (Read 2 times) previous topic - next topic

Magician

Yes, probably it would not work.
I just try to give a tips, not a programm. The tips are you have a deal with timing,
and should use a time checking subroutine, like millis();
I think in my example there is a timing issue, as it overwrite newvalue any cycle.
And photoresistors are slow devices, so value from the sensor couldn't change fast enough.
Put a delay(500), after last line, it will slow the speed.

Groove

Code: [Select]
int oldvalue =0, newvalue =0;

oldvalue= newvalue; //


I think a "static" qualifier for oldvalue could be useful
Per Arduino ad Astra

Go Up