i'm measuring sunlight , lcd screen supposed on when bright , off when dark.with code have no problem measuring light.lcd on when bright when darken ldr, lcd not turn off, stays on.am missing here?
code: [select]
double light (int rawadc0)
{
double vout=rawadc0*0.0048828125;
double lux=(2500/vout-500)/10;
return lux;
}
void setup()
{
pinmode(a3, output);
serial.begin(9600);
}
void loop() {
serial.println(int(light(analogread(0))));
delay(1000);
if ( analogread(0) > 15)
{
digitalwrite(a3, high);
}
else
{
digitalwrite(a3, low);
}
}
put value analogread(0); in variable , use instead of reading twice. try printing value. see ?
15 seems low value @ switch lcd on/off don't know setup.
15 seems low value @ switch lcd on/off don't know setup.
Arduino Forum > Using Arduino > Programming Questions > [Solved]If and high-low code problem
arduino
Comments
Post a Comment