Hi all
Can any one trll why my code doesn't work ;
i wont to connect ldr sensor to esp32

but it dosent work the outlight pin dosent give me low why
const int ldr =23;
const int outlight = 25;
void ldrlamp();
void setup{
pinMode(ldr, INPUT);
pinMode(outlight, OUTPUT);}
void loop() {
ldrlamp();
}
void ldrlamp(){
if(digitalRead(ldr)==1){
digitalWrite(outlight, LOW);
}else{
digitalWrite(outlight, HIGH);
}
}
Correct the above and rerun the sketch.
1 Like
jim-p
3
Do the two LEDs light up?
I don't under stand what U mean
Yes the both light up and Do when.i cover it light off
Does your sketch compile?
jim-p
7
But as @GolamMostafa has pointed out, your sketch does not compile
Yes it's compile corectly
It is compile with
But i found another way to solve this proplem i connect the Do directly to INT to the relay and it's work fine
jim-p
10
If you found a bettor way I won't try to convince you to do something different.
Glad it worked.
1 Like
I thank you for your support thank you very much
It is surprising that your sketch works without correcting ––
void setup{
==> void setup(){
1 Like
system
Closed
13
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.