How can i make automatic light switch? arduino

I used this website to make my auto light switch and everything works, that is, when you enter the room, the switch turns on, but I don’t know how to make it so that when you leave the room, the light turns off

Help us help you.

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Please post a schematic.

Please post an image of your project.

Please describe the problem better then you just did.

Right on that page, it says:

"This can be modified to turn off the light also, but for that, you'll need two ultrasonic sensors to count the people entered the room and how many of them left the room so that it can operate accordingly."

Whilst someone is in the room the sensor can be arranged so it keeps triggering off the person - that can be used to keep the light on .
Just arrange for the light to time out and switch off if no trigger signal is detected .

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.