#๐ Need help changing code so my ldr turns my led off when its not dark but turns on when it is dark
22 messages ยท Page 1 of 1 (latest)
@blissful niche
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Are you getting errors? Or what specifically is not working?
I notice that there is no such thing as rgb.value and I dont think you need the rgb.value = ldr.value line all together
I want my rgb led to turn on only in the dark using the ldr which it isnt doing, not getting errors
Is the ldr a photoresistor? Could it just be your values are off. Is 0.4 not dark enough?
yea the ldrs a photoresistor
You could add a print statement to see what the ldr is currently reading
the ldr value says its reading 0.00
Does it change when the light changes?
I think you might need to check the wiring
Make sure it is actually in Pin 27 and one lead has 5v power
ok
And that pin 27 is an analog pin
o
my ldrs reading a valuye of 0.12 now
now you just need to measure what it reads when it is light and when it is dark and pick a value in between to replace 0.4
thanks
it works tysm
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Need help changing code so my ldr turns my led off when its not dark but turns on when it is dark