Project Description

NightLight consists of a LED that can be manipulated through multiple sensors to act as a night light. A digital button in the Blynk app toggles the state of NightLight between 'active' and 'inactive'. While the NightLight is active, a light sensor will toggle the LED on if the ambient light drops below a certain threshold, and will toggle the LED off again if the ambient light turns back on. While NightLight is set to be active using Blynk, and the ambient light level is low, users can toggle the LED using a pushbutton. If it is inactive or if the ambient light is high, the button does not affect the state of the LED. We chose to create NightLight because we were motivated by not wanting to trip over things in the dark and hurt ourselves or break furniture. :)


  • Mac: Hardware and code, emphasis on software
  • Wenyao: Hardware and code, emphasis on hardware


  • Arduino MKR1000 Wifi
  • pushbutton
  • LED
  • light sensor

Technical Details

Initially, we considered setting up the various components of our project on a complicated circuit, where the behavior of our sensors would directly affect the LED and other components through the circuit. However we quickly realized that it was best to have each sensor or LED connected to the Arduino completely separately, and handle all of the logic in the code. The Arduino program runs on a basic loop: on each iteration of the loop, the program checks the state of the light level, whether or not the system is turned off through a Blynk virtual pin, and whether or not the button has just changed state. Based on these criteria, it writes either a high or low value to the LED, waits 10 milliseconds, and simply checks the same criteria again on the next loop. The threshold to determine whether it is light or dark is stored in a single global variable so that users can easily adjust the threshold to their needs.

Initial Project Proposal

"There will be a push button that toggles the state of the NightLight between 'active' and 'inactive'. While the NightLight is active, a light sensor will toggle the LED on if the ambient light drops below a certain threshold, and will toggle the LED off again if the light turns back on. While the NightLight is active and the LED is off, a microphone will detect spikes in noise and will turn the LED on. This is intended to respond to a user making a clapping sound in the dark to activate the light. Additionally, while NightLight is active, users will be able to toggle the light through IoT with wifi connectivity. If NightLight is inactive, no other sensors will affect the LED."

Iteration on Original Proposal

Originally our proposal included a microphone so that users could activate or deactivate the light with a clapping noise. However we decided that this would be inconvenient for users and that the microphone would be too sensitive to unintentional noises, leading to unintended results. The final version of NightLight simply includes the Blynk virtual button and the pushbutton for manual user input, which is easier to control than a noise-activated sensor.

Possible Improvements/Real World Implementation

NightLight could be improved in many ways. In the prototype, a red LED is used as the light which works to guide someone in a dark room but does not really give off enough light to be useful as a source of illumination. This could be swapped out for a brighter light, although a different power source and circuit configuration might be necessary. Additionally, while the light is red to allow users' eyes to easily adjust to the dark, the red LED could easily be swapped out for a different color such as a white light. Other modifications such as a more self-contained case could be useful for people who do not want their circuit to get damaged, or who would want to cover up the green light on the MKR1000.

Video Advertisement/Demo


Built With

Share this project: