Need Help With Project, LDR, PIR, LED (Arduino)

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Kenny407
 
Posts: 4
Joined: Sat Apr 04, 2015 2:06 am

Need Help With Project, LDR, PIR, LED (Arduino)

Post by Kenny407 »

Hey guys, I'm new to micro controllers and need some help with my final project for school. I'm doing a smart street lighting system, the major components are:

LDR Sensor
PIR Sensor( Parallax)
LED
220 ohm resistor
10k ohm resistor
Arduino UNO R3 SMD
Transistor 2N3904

Basically how it works

1, Once the LDR sensor detects its dark out the motion sensor will become active
2. If nothing is in the range of the motion sensor the led will be dimmed down
3. If something triggers the motion sensor the LED will go to full brightness for 5 seconds and then dim down again

Thats the basic operation of the system it will be powered by a 12v 8ah battery that is hooked up to a 10w Solar panel. I had it working with just the photocell, once i added the code for the pir motion sensor the led just stays on continuously and doesn't turn off. I haven't yet added the dimming/ brightening part yet and don't really know how to, I was going to use the 2n3904 transistor to regulate the voltage to the led but if you guys have a better idea let me know.

Anyways heres my circuit diagram and code that im using

Image
Image
Image

if you want to try the code heres a link
http://www.tinkerhobby.com/motion-and-l ... ent-139574

Any help would be greatly appreciated guys, Im so lost when it comes to this stuff ( Im a hydro stream guy, never touched a micro controller )

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Need Help With Project, LDR, PIR, LED (Arduino)

Post by adafruit_support_bill »

once i added the code for the pir motion sensor the led just stays on continuously and doesn't turn off.
That doesn't make sense with the code you posted. Even if the PIR sensor were stuck on, the LED should turn off for 1 second after being on for 5 seconds.

Code: Select all

I haven't yet added the dimming/ brightening part yet and don't really know how to
It is actually quite simple to do with PWM. You don't even need the transistor.
https://learn.adafruit.com/adafruit-ard ... ss-control

User avatar
Kenny407
 
Posts: 4
Joined: Sat Apr 04, 2015 2:06 am

Re: Need Help With Project, LDR, PIR, LED (Arduino)

Post by Kenny407 »

Thanks for the code for uthe dimming, and yeah im just trying to get the photocell and motion sensor part to work right now but its not going to well lol

User avatar
The_Electro_Junkie
 
Posts: 8
Joined: Sun Mar 29, 2015 11:13 am

Re: Need Help With Project, LDR, PIR, LED (Arduino)

Post by The_Electro_Junkie »

Your PIR Sensor does not have a trigger selector. Maybe you need a different PIR. The trigger selector allows it to remain on until reset after detection of motion or to stay on for only 5 seconds. May be possible with code but I am not famillar with that sensor.

User avatar
Kenny407
 
Posts: 4
Joined: Sat Apr 04, 2015 2:06 am

Re: Need Help With Project, LDR, PIR, LED (Arduino)

Post by Kenny407 »

Well thats no good which sensor do I need?

User avatar
Kenny407
 
Posts: 4
Joined: Sat Apr 04, 2015 2:06 am

Re: Need Help With Project, LDR, PIR, LED (Arduino)

Post by Kenny407 »

Got it working, now i just have to disable the circuit from working when its light out and add the dimming

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”