[Lab] PIR, IRF540, PN2222, LED Strip, Arduino

Ken McKinnon klmckinnon at rogers.com
Sun Mar 18 11:47:01 EDT 2018


OK, long answer.

 From your Fritzing, I get this as the schematic, please correct me if I 
am wrong...



It is a bit ironic as the computer I am using did not have Fritzing on 
it, but it did have Eagle, so... downloading Fritzing now...

As a note, you can flip to schematic mode in Fritzing and shuffle the 
parts around to get a proper schematic.

The arduino would turn pin 5 on after detecting movement on the PIR 
sensor (not shown), making pin 5 Hi for some duration (900 ms + 
detection time)

The transitor configuration is an inverter, so the high would turn the 
transistor on (Base) and make the collector low for that time period.  
This goes to the drain of the MOSFET (P2) while the gate (P1) is tied to 
ground(?) and the load is from the source (P3) to ground(?)

 From the datasheet.... You want a positive pulse on the gate, with some 
decent voltage, so using the transistor to drive the fet is good, but I 
don't think you are using the proper configuration.

Based solely on the parts you have selected, I think you want the 
transistor to be in an voltage follower configuration, with the output 
going to the gate of the MOSFET (P1).

Something akin to this...

Fritzing downloaded....finally

But it all depends on your final use.  If it is learning, or an 
experiment, etc, that is one thing, but if it is to be a problem 
solution, I would recommend approaching it from a simplier and cheaper 
angle:  Chuck the arduino back into the bin for another use, and use a 
simple 555 timer IC (8 pins) with an RC circuit set to your timeout, the 
sensor as the trigger in, with the rest of the driver circuit as is.  
Sometimes a microcontroller is really just overkill (hate to say that, 
but...).

Ken


On 2018-03-17 9:59 PM, Bruce Harding wrote:
> my fritzing diagram.  I know it does not work. It was as close as I 
> could get to what I think should work.
>
> On 17 March 2018 at 21:28, Ken McKinnon <klmckinnon at rogers.com 
> <mailto:klmckinnon at rogers.com>> wrote:
>
>     Centerpointe library at 1 pm.
>
>     https://www.google.ca/search?q=centerpointe+libery+nepean&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&dcr=0&ei=zb-tWqzUMe_OXvLukbgO
>     <https://www.google.ca/search?q=centerpointe+libery+nepean&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&dcr=0&ei=zb-tWqzUMe_OXvLukbgO>
>
>
>>         On 2018-03-17 8:27 PM, Bruce Harding wrote:
>>>         I download fitzing and try to do a diagram.
>>>
>>>         Bruce
>>>
>>>         On Sat, Mar 17, 2018, 8:01 PM Ken McKinnon,
>>>         <klmckinnon at rogers.com <mailto:klmckinnon at rogers.com>> wrote:
>>>
>>>             I think if you might help yourself (and us) by using a
>>>             graphic circuit drawing tool like fritzing which is a
>>>             circuit drawing tool that (I think) was made for the
>>>             arduino landscape.
>>>
>>>             http://fritzing.org/home/
>>>
>>>             Trying to picture your cicuit based on what you describe
>>>             is a bit difficult.  At best, I can think that your PIR
>>>             might need a pull-up for the input, and I'm not sure why
>>>             you need a mosfet and a transistor..?
>>>
>>>             Your code looks OK at a first glance, pretty basic, but
>>>             OK.  Of course, you are wasting a lot of horsepower for
>>>             a circuit that could be handled by a 8 pin 555 timer IC,
>>>             but ...
>>>
>>>             Ken
>>>
>>>
>>>
>>>             On 2018-03-17 3:10 PM, Bruce Harding wrote:
>>>>             Hello,
>>>>
>>>>             I'm trying to get the pinning right for a project where
>>>>             a PIR triggers a LED strip to turn on.  I'm having real
>>>>             trouble getting the pinning on the breadboard right. If
>>>>             someone is willing to take a look at it I'd be
>>>>             grateful. Beer or coffee on me.
>>>>
>>>>             I'm using:
>>>>
>>>>             12v 3A power supply
>>>>             PIR
>>>>             IRF540 Mosfet
>>>>             PN2222 Transistor
>>>>             1m Warm/White LED Strip
>>>>             Arduino Uno
>>>>
>>>>
>>>>             Code:
>>>>
>>>>             //constants
>>>>             const int ledPin = 5;
>>>>             const int sensorPin = 4;
>>>>             const long stayOnPeriod = 900;   // length of time to
>>>>             stay on (in milliseconds)
>>>>
>>>>             //variables
>>>>             unsigned long turnOffTime = millis();  //Start with the
>>>>             led turned off
>>>>
>>>>             void setup() {
>>>>               pinMode(ledPin, OUTPUT);
>>>>               pinMode(sensorPin, INPUT);
>>>>             }
>>>>
>>>>             void loop() {
>>>>               // check if the sensor is detecting then increase the
>>>>             time to stay on.
>>>>               if (digitalRead(sensorPin) == HIGH)
>>>>               {
>>>>                 turnOffTime = millis() + stayOnPeriod; //e.g. 128 +
>>>>             256 =384
>>>>               }
>>>>
>>>>               if (turnOffTime > millis()) //384 > 129
>>>>               {
>>>>             digitalWrite(ledPin, HIGH);
>>>>               }
>>>>               else
>>>>               {
>>>>             digitalWrite(ledPin, LOW);
>>>>               }
>>>>             }
>>>>
>>>>
>>>>             -- 
>>>>             ====
>>>>             bruce
>>>>             faintfuzzies.ca <http://faintfuzzies.ca>
>>>>
>>>>
>>>>             _______________________________________________
>>>>             Lab mailing list
>>>>             1. subscribehttps://artengine.ca/mailman/listinfo/lab
>>>>             <https://artengine.ca/mailman/listinfo/lab>
>>>>             2. then emailLab at artengine.ca <mailto:Lab at artengine.ca>  to send your message to the list
>>>
>>
>>
>>
>>
>>     -- 
>>     ====
>>     bruce
>>     faintfuzzies.ca <http://faintfuzzies.ca>
>
>
>
>
> -- 
> ====
> bruce
> faintfuzzies.ca <http://faintfuzzies.ca>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://artengine.ca/pipermail/lab/attachments/20180318/68b9bdbe/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mckfhbcopbjiifnb.png
Type: image/png
Size: 3418 bytes
Desc: not available
URL: <https://artengine.ca/pipermail/lab/attachments/20180318/68b9bdbe/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: epdhdajnhehjcdhd.png
Type: image/png
Size: 9697 bytes
Desc: not available
URL: <https://artengine.ca/pipermail/lab/attachments/20180318/68b9bdbe/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ceecoapndijlooep.png
Type: image/png
Size: 6036 bytes
Desc: not available
URL: <https://artengine.ca/pipermail/lab/attachments/20180318/68b9bdbe/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: knbebeglcknfhfdp.png
Type: image/png
Size: 2991 bytes
Desc: not available
URL: <https://artengine.ca/pipermail/lab/attachments/20180318/68b9bdbe/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mbmppkagolpjafbb.png
Type: image/png
Size: 81053 bytes
Desc: not available
URL: <https://artengine.ca/pipermail/lab/attachments/20180318/68b9bdbe/attachment-0009.png>


More information about the Lab mailing list