My simple LED strip controller, Part 3

The software

The main idea driving the hardware was to keep it as simple as possible on the software side. Simple can mean a lot of things but in the microcontroller world the word is mostly associated with Arduino which is what we’re also using here.

Light sensor

We only want to turn on the light if it is sufficently dark outside. For this we’re using a light detecting resistor in a voltage divider setup connected to an analog digital converter at the MCU. In order to not constantly burn power we’re also using an output pin to turn on the power when we want to sense the current light level. Daylight doesn’t change often and/or quickly so we don’t need to check the light levels too often.

Motion detector

The motion sensor will put a high level on a pin when motion is detected. To keep the hardware simple, the motion sensor will run all the time and pull the pin high with every detection of motion. However we’ll only care about the motion when the ambient light is low enough. So once we’re in this modus operandus we’ll simply set up a countdown variable determining how long we’ll keep the output pin connected to the MOSFET high. During this time we’ll also check whether something keeps on moving and if it does we’ll replenish the counter. Once the counter is up, we’ll turn off the light and go back to checking the light sensor.

The MOSFET

The original plan was to make the light PWM dimmable with the darkness. However, as it turned out, the pin I chose is not PWM capable so unless I make a hardware modification (which I’ll likely do sometime later since I’m really not in the mood to do half-assed soft-PWM)… As a first start we’ll simply turn the output pin on and off.

To be continued …