Picture of Motion Sensing Micro-Processor Controled  Night Light
Getting up at night to go to the bathroom or whatever has just gotten a whole lot better on the account of my motion sensing nightlight
I place this under the bed and as soon as you get up the sensor will detect motion and on comes the light.  

This night light uses the popular PIR sensor to detect movement.
Then the ATtiny 2313 processes the signal and turns on the LED's for the set 2 minute, then off and waiting for another signal. 
Repeat and repeat.

Step 1: ATtiny2313 vs ATtiny85

Picture of ATtiny2313 vs ATtiny85
So why use a ATtiny2313 and not an ATtiny85, when a ATtiny85 seams to be the more logical one to use?

The ATtiny2313 has many more pins than this project could ever use. Over kill on the pin count.
That also makes it psychically bigger that say a ATtiny85. 20 pins instead of just 8.
It doesn't have the byte capacity of a ATtiny85. ATtiny2313 has 2K bytes verses the ATtiny85 8K bytes.

Like most everything it comes down to cost. The ATtiny2313 is the cheapest micro-processor i can get in my area, when shipping ect is factored in.
ATtiny2313 is $1.75 USD. Where as an ATtiny85 is $4.50 each if i buy 2. 

ATtiny2313 PDF

diy_bloke3 months ago

With just a quick look I got the program down to 984 bytes (in IDE 1,0) and 916 bytes (in IDE 1.6). that way it would fit in an attiny10 that is even cheaper than the 2313.
getting those last bytes off:
dont use constants for the pin numbers, just use the pin numbers.
shorten the names of your variables to 1 character

don't use 'int' for only storing small numbers, use 'byte'

diy_bloke3 months ago

with regard to cost: if you havent already.... check out aliexpress. I know this instructable is 2 years old, but even then 4.80 for an attiny85 is outrageous.
I think currently when bought in bulk the attiny2313 is 70 euro cnts and the 85 some 95 eurocents

pete543211 year ago
Is it possible to have this only turn on at night?
Somewhere between 11pm and 5am or so?
WWC (author)  pete543211 year ago
That would be different. This a motion sensing light not a light operated by a timer.
If you search on here you will find what you are asking about.
Ridach2 years ago
I was wondering if i can set this up with a 12v dc adapter and the led strip lights, I want to make it so the stairs light up when someone it at the top or the bottom of the stairs, thanks
WWC (author)  Ridach2 years ago
You are wanting to use 12v because your led strip uses 12v i am guessing.
The answer is yes, BUT in supplying 12v to the circuit board that only requires 5v then you will have to burn off 7v. Instead of using the 78L05 voltage regulator that i have used I would switch to a LM7805 voltage regulator and use a heat sink for it if it is getting hot.

Are you planning on making 2 circuits, one for the top of the stairs and one for the bottom or connecting 2 PIR sensors together into one circuit?
Ridach WWC1 year ago
Thanks for the info, Well i was hoping that i could get 1 to work, but i thought i might need 2 pir sensors , which way would be best ,
WWC (author)  Ridach1 year ago
You would need 2 PIR sensors what ever way you build the system. One for the top and one for the bottom. I would take the fresnel lens off of them and put a small tube over the eye to make it very directional or else they will pick up movement other that what you want.
Other than that which way is better is subjective depending on who is building it ect. Either way you will have wires running up and down the stairs several times unless you went wireless.
The 2 main ways i spose is have each PIR go into one controller or build 1 controller for each PIR, that you will have to decide.
One thing is if you used 2 controllers you would not have to change the program. If you used one controller you will need to change the program. I don't know how comfortable you are with Arduino programming.

I would like to see what you build.
Good Luck

Toby Robb1 year ago
sorry im not sure what you mean. don't call it in a separate function? like an interrupt?
WWC (author)  Toby Robb1 year ago
I was a little off on that please see here
Toby Robb1 year ago
Nice one. Ive made something similar. However i used a mosfet transistor to switch a single high power led. I used the atmega 328. but im going to build an attiny85 version. have you used the chip much?
WWC (author)  Toby Robb1 year ago
I was a little off on that, please see this
WWC (author)  Toby Robb1 year ago
Yes i have. One thing you want to watch out for with the ATtiny85 is not to use analog read. It has the ability but the function is already understood so it doesn't like to be called.
Toby Robb WWC1 year ago
Ahh ok thanks I was gonna use tue analogRead function but thats disappointing if it doesnt work.
WWC (author)  Toby Robb1 year ago
I am slightly wrong on this please see my old thread
WWC (author)  Toby Robb1 year ago
It does work just do not call it.
Strontium2 years ago
cool circuit,you could even fix this inside a laundry room or somewhere else so that in case you walk in with your hands full it will automatically turn itself on.
WWC (author)  Strontium2 years ago
Great idea. There is many variations of this that could conkocked.
shannonlove2 years ago
Voted: Clever and useful. You might consider developing this. At least run it by quirky or the like.

As an enhancement, you should consider using the red LED. You might need to check the spectrum but red light does not interfer with night vision. So, if your light goes off, the power goes off, you go to another dark room etc, you can still see.

I had a red light night light years ago I put in my bathroom. Made a big difference sliding back into bed trying not to wake the spouse. With the red light, I could see plainly in the dark when I came back to bed, without it, well, there was spousal grumpiness in the morning. Wish I could find those again. 
WWC (author)  shannonlove2 years ago
Great tip about the Red LED's. I will try it.
Who is quirky?
shannonlove WWC2 years ago
Quirky.com, they do "crowdsourced" product development. I might also recommend Fastcap at Fastcap.com. They do mostly woodworking equipment but increasingly they do product consumer development. People send them ideas and if they develop them, they give you a fixed precentage off the top of the revenue. Pretty sweet deal if you've ever tried the nightmare of developing yourself e.g. patents, marketing, etc. I think there are a few others. Just stay away from anyone who ask for money up front.
WWC (author)  shannonlove2 years ago