🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

Night Light
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Night Light

by Emily_Lynn on Thu Nov 28, 2019 1:23 pm

Hello, I am attempting to make a simple night light that is affected by brightness. When the lights in a room are turned on, the LEDs are off. While the lights are turned off, it turns on and glows.

On the simulator it works fine, although when programmed into the actual thing, the brightness does not work. I have been told it has to do with the brightness of the LEDs themselves that are interfering with the light sensor.

My question is, is that possible and how can I fix it?

Screen Shot 2019-11-28 at 12.08.13 PM.png
Screen Shot 2019-11-28 at 12.08.13 PM.png (769.28 KiB) Viewed 78 times

Emily_Lynn
 
Posts: 2
Joined: Thu Nov 28, 2019 12:31 pm

Re: Night Light

by adafruit_support_bill on Thu Nov 28, 2019 1:36 pm

It is possible for the on-board LEDs to interfere with the light sensor. The sensor has a field of view that is almost 180 degrees. You can restrict that to a narrower angle by blocking light from hitting the sensor from the side.

You may also be able to deal with it by simply adjusting the light level threshold in your if/else block.

adafruit_support_bill
 
Posts: 75326
Joined: Sat Feb 07, 2009 10:11 am

Re: Night Light

by Emily_Lynn on Thu Nov 28, 2019 3:17 pm

What would I use ti block out light? Because when it launches, the lights are automatically on.

Also, how do I adjust the light level threshold?

Emily_Lynn
 
Posts: 2
Joined: Thu Nov 28, 2019 12:31 pm

Re: Night Light

by adafruit_support_bill on Thu Nov 28, 2019 6:08 pm

If the lights are on at the start, then interference from the LEDs is not the problem. Try increasing the threshold in your if/else block. Currently you have it set to 100. Try increasing that number.

adafruit_support_bill
 
Posts: 75326
Joined: Sat Feb 07, 2009 10:11 am

Re: Night Light

by jim_lee on Fri Nov 29, 2019 2:34 am

Shut off your light.
Check the ambient light
Adjust your light level.
turn on your light
wait a bit
repeat.

If you're quick, you should never see the flash.

-jim lee

jim_lee
 
Posts: 577
Joined: Thu May 24, 2012 8:24 pm

Please be positive and constructive with your questions and comments.