In this project I will show you how to build a light switch that will turn on the lights when you enter the room.
This project will be build using an ATtiny85 but you could use a Arduino board if you would like. I chose to use an ATtiny85 as it will reduce the amount of space the circuit will take up in the light switch box.
The circuit will be powered by a small 5v power supply (shown below). So that the power supply will work you will need to make sure that your light switch box has a neutral wire in it because without it the device wont work.
The circuit will use a PIR sensor to sense when someone has entered the room and the lights will be turned on by a relay.
Try to keep all the wires as short as possible to save space. I would recommend using a PCB to keep all the components together so nothing gets connected incorrectly.
Now you will need to program the ATtiny85 to do this follow my tutorial on how to do it using a Arduino Uno Once the attiny85 is programmed insert it back into the IC socket. I have provided the code for you below.
Once you have built the circuit you can take a normal light switch and drill a 10mm hol using a Arduino Uno light switch then use hot glue to secure the PIR sensor to the light switch.
After every thing is assembled turn off the power to your lighting circuit and insert the live and neutral wires into the screw terminals for the power supply and connect the live to the relay then the switched live wire to the normally open relay screw terminal.
Turn back on the power to your lighting circuit and test to see if the device works. You may need to adjust the potentiometer on the PIR to set how sensitive the device is.
In the code you can change the amount of time the lights will stay on for after the sensor has been triggered and if you want to have the lights continually on you can use the switch.