Creating Night Light

Hi having trouble creating night light that activates only at night and when my ping sensor reads that you are there then turns off once you are gone please help!!

Post what you have tried and describe any problems or errors encountered.

What type of sensors are you using ?

I want to use a ping sensor and a photo resistor

Wondering if you could help with code because there is no code for a ping sensor night light and I don't know much yet :slight_smile:

Should be pretty straightforward to combine the two.

  1. write the code for a "night light",

  2. write the code for the "ping sensor",

1+2) code for "ping sensor" that only runs when the "night light" is active.

So you get something like:

if ( {
  if (ping.detectObject()) {

Of course up to you to fill in the functions, and you may want to add a delay before switching off the light. Just look at the "blink without delay" code on how to implement delays by keeping track of time using millis().

Thank you so much :slight_smile:

comes up with error's because I do not know what the code for the ping is

I got half a million hits on Google, of which the first two were tutorials.