Let's get to work!
Once again, let's begin by making a high-level block diagram of this project as shown in the following diagram:
Let's now outline how this will all work together.
When our device senses that there is enough ambient or surrounding light, it will keep an attached LED off. But when then ambient light level goes below a certain threshold meaning the surroundings have gone dark, the device's light will turn on, more importantly, automatically!
We will be using conditional statements again and the flow chart is as follows:
According to our flow chart, the sensor will constantly check the ambient light levels in a loop.
If there is enough light, the LED will stay off, but when the ambient light levels goes below a certain threshold, the LED will be turned ON.