Ambient Light To Frequency Circuit

Thread Starter

dcbingaman

Joined Jun 30, 2021
1,065
With that in mind and using a uC I would consider sensors like these considering you can buy 4 of them for about $7.00 USD. Using a uC I would just take the Analog Out from sensor and map it to 0 to 255 for a PWM out to drive your LED display brightness (intensity). There are plenty of similar modules off the shelf. Note your analog input levels and just convert the range you have by mapping to a PWM out and use a simple MOSFET to drive your LEDs, depending on your LED current requirements.

I don't see where a V to F is going to get you a change in LED brightness. normally isn't PWM used for this?

Ron
In response to your last question, a PWM is being used to change LED brightness. The V/F was just a means to convert the ambient light sensor to a 'digital' signal as opposed to an analog signal. Sorry for the confusion.
 

MrChips

Joined Oct 2, 2009
34,850
You don't even need an MCU with on-board ADC.
An LDR and capacitor into a GPIO pin will do it. Measure the charge or discharge time of an RC circuit connected to an I/O pin.
Here are two ways to do this.
GPIO RC measurement.jpg

In A, the MCU GPIO pin is first configered as an output. Send out logic LOW to discharge the capacitor. Turn the GPIO to input and measure the time it takes to charge C1 above the input threshold.

In B, the MCU GPIO pin is set to output logic HIGH. Turn the GPIO pin to input and measure the time it takes to discharge C2 below the input threshold.

For greater accuracy, use interrupt on pin change and repeat this cycle for a fixed time interval. With this procedure, you will be measuring the frequency of oscillation instead of measuring a single period.

The advantage of measuring a single period is that the result is directly proportional to RC.
 

Reloadron

Joined Jan 15, 2015
7,891
In response to your last question, a PWM is being used to change LED brightness. The V/F was just a means to convert the ambient light sensor to a 'digital' signal as opposed to an analog signal. Sorry for the confusion.
Well alrighty then. My initial thought was to have dash lights change brightness based on outside ambient light. My read now is you just want to set a threshold where lights go from full bright to maybe 1/2 full bright? The board I suggested earlier affords two outputs, a digital out where you set the digital out threshold based on amount of ambient light or an analog out proportional to amount of ambient light. Both options are onboard.

A simple basic circuit using a LDR looks like this:
LDR Light Dark.png

The difference is the circuit on the left the Vout increases with darkness while the circuit on the right Vout decreases with darkness. Using a small uC it's just a matter of how you write your code. You do not need much. The Vout in the above will be an analog out going to your uC. You choose the series resistance based on the Light and Dark values of your LDR. Within your code which is very simple you want hysteresis.

Yes, no shortage of ways to find yoursolution. :)

Ron
 
Top