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

Bruce Harding bsharding at rogers.com
Sat Mar 17 22:01:18 EDT 2018


My fritzing diagram. It doesn't work, but it is as close as I could get.

On 17 March 2018 at 20:01, Ken McKinnon <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
>
>
> _______________________________________________
> Lab mailing list
> 1. subscribe https://artengine.ca/mailman/listinfo/lab
> 2. then email Lab at artengine.ca to send your message to the list
>
>
>


-- 
====
bruce
faintfuzzies.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://artengine.ca/pipermail/lab/attachments/20180317/3007d4f1/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pir_led_mosfet540_bb.png
Type: image/png
Size: 403671 bytes
Desc: not available
URL: <https://artengine.ca/pipermail/lab/attachments/20180317/3007d4f1/attachment-0001.png>


More information about the Lab mailing list