Go Down

Topic: how i put string value from BH1750 -light sensor to if else condition? (Read 494 times) previous topic - next topic

Lucinecka00

working code :

Code: [Select]


lightMeter.begin();
uint16_t lux = lightMeter.readLightLevel();
lcd.setCursor(0,1);
lcd.print("Int=" + (String)lux + " lux   ");


what i mean to put there:


   
Code: [Select]
if (digitalRead((String)lux) <= (1200))
    { finished = millis();
    stop millis();
    delay(200);
    displayResult();
    stop count++;
    stop(x);
   
   

    }

    else (digitalRead((String)lux) > (120));
    { continue;
}

groundFungus

Code: [Select]
if (digitalRead((String)lux) <= (1200))
DigitalRead does not take a String as a parameter.   It takes a pin number (int).  Is there really a lux pin to read?  DigitalRead returns a HIGH (1)  or a LOW (0).    So always less than 1200.  Can you explain what that is supposed to do?

Maybe what you want is:

Code: [Select]
If(lux <= 1200)


Code: [Select]
else (digitalRead((String)lux) > (120));
The else structure takes no arguments. 

CrossRoads

"It takes a pin number (int)."  byte. There are no pins above 255. 
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up