Hi all, sorry if this has been asked before, I've been looking and have seen similar questions but not exactly this question so I was hoping for some guidance.
I first made it so that the motion sensor would turn on a simple LED if it sensed movement, so that's all good, but now I'd like to turn on a light bulb (shown in picture attached) inserted into a light bulb socket, but I'm not entirely sure how it should all be setup since I'm pretty new to this.
I was told I needed a relay but I'm not entirely sure how to use it with the cables from the light-bulb socket or if that's even possible (don't wanna end up getting electrocuted or something).
So I'd like a bit of guidance. Is what I'm trying to do possible with the materials I have?
And how would the two cables from the light-bulb socket go with the rest of the project (I'm assuming they go into the relay but all images and videos I've seen use a wall adapter instead of the 9V battery so not sure).
Thanks in advance for any help!
TL;DR: How to use PIR motion sensor to turn on light-bulb attached to socket with Arduino + Relay and 9V battery
I have:
A 9V battery
....but all images and videos I've seen use a wall adapter instead of the 9V batter
Get rid of it and use a proper power source, i.e. virtually anything other than a 9v PP3. You may find that you can use the 9v (for a short time) later but, at the moment it may be more of a liability than an asset, and you will be better off proving the point with the wall wart.
You probably need to be more forthcoming about the characteristics of the light bulb. The way things are at the moment, Arduino could be redundant.
I do have an AC Adapter I could plug into the Arduino to replace the battery, though I wouldn't know how to incorporate the lightbulb into that either. Would I just connect the - to the gnd and + to the pin I programmed for the light (pin 13)?
As far as the lightbulb goes, I'm not too sure about the specs since I got it from a friend, I think it said 127V + 10% on it though. I'm basically just trying to make a lamp that turns on when detecting movement, so I could totally change the bulb as well if it's too much. What do you think?
Well I think that playing with mains electricity is dangerous if you don’t know what you are doing, and clearly you don’t. Are the relay contacts rated for mains voltage and for the current the lamp will switch?
As to the wiring of the relay you would not have to ask if you were up to doing this. But purely as a learning excise what you need to do is connect one wire from the lamp to the common relay contact and connect the normally open contact along with the other wire of the lamp to the mains.
Howeve,r be aware that when the light is off there will be mains voltage on the normally closed terminal that you could have an accident with. There are also regulations regarding the spacing between circuit carrying mains voltage and other circuits, known as creepage and clearance.
You need a good quality layout and physical protection of the mains wiring.