Arduino to Transistor and LEDs controlled by PIR sensors

Hello Arduino forum,

Working on a project using an Arduino, PIRs and transistors to control groups of LEDS.

​called Staircase lit by LEDS controlled by PIRs​​​

Having the devil of a time getting it to work so I simplified the system down to one PIR

and one group of LEDs

Still can't get it to operate the LEDs.

So to just get something to work I simplified it further thinking there might be a power problem

with 18 LEDS,

Still no joy.

So to test that a signal was coming from Arduino pin A0 I connected the output from the microcontroller,

thru a resistor to the LED.

The LED then operated as expected.

(The Arduino sketch, copied herewith below is pretty simple. It declares to variables, one for the sensor input,

and for ouput to the LED and then tells the LED if it gets a signal from the PIR to turn the LED on for one

second.)

So there is something wrong in the area marked 'Control Board'. I tried putting a probe at R1 and to ground

and there is a 5 volt signal coming from the Arduino for a second after there is movement at the PIR.

So I think there is some defect in the logic at the transistor but can't figure it out.

Thanks.

Allen in Dallas

/*  
    Arduino with PIR motion sensor
    For complete project details, visit: http://RandomNerdTutorials.com/pirsensor
    Modified by Rui Santos based on PIR sensor by Limor Fried
*/
 
int led = A0;                // the pin that the LED is atteched to
int sensor = 2;              // the pin that the sensor is atteched to
int state = LOW;             // by default, no motion detected
int val = 0;                 // variable to store the sensor status (value)

void setup() {
  pinMode(led, OUTPUT);      // initalize LED as an output
  pinMode(sensor, INPUT);    // initialize sensor as an input
  Serial.begin(9600);        // initialize serial
}

void loop(){
  val = digitalRead(sensor);   // read sensor value
  if (val == HIGH) {           // check if the sensor is HIGH
    digitalWrite(led, HIGH);   // turn LED ON
    delay(1000);                // delay 1000 milliseconds 
    
    if (state == LOW) {
      Serial.println("Motion detected!"); 
      state = HIGH;       // update variable state to HIGH
    }
  } 
  else {
      digitalWrite(led, LOW); // turn LED OFF
      delay(200);             // delay 200 milliseconds 
      
      if (state == HIGH){
        Serial.println("Motion stopped!");
        state = LOW;       // update variable state to LOW
    }
  }
}

The 10 Ohm resistor is way too low in my opinion. It will run some 3 - 400 mA through the diode. That LED couldn't feel well.
The transistor, some BD... Could that be a Darlington?

10 ohm could be ok for a 300mA LED array.
The transistor is a 50-year old medium power type, that could use some more base current (220 ohm).

Are you sure the PIR is ok.
I would test that first with the build-in LED of the Arduino (no other parts/LEDs connected, USB supply).
You seem to use pin2 for the PIR.
Try this, assuming you're using a HC-SR501, have turned the 'time' pot on the PIR fully anticlockwise and left the 'sensitivity' pot in the middle.
Leo..

void setup() {
pinMode(13, OUTPUT); // build-in LED
}

void loop() {
digitalWrite(13, digitalRead(2)); // LED follows pin2
}

The obvious thing which could go wrong in the area marked control is, having read the transistor pinout correctly from the data sheet, applying it to the transistor turned upside down .

Here, for example, is plenty of scope for error in the rather poor illustration:

If you have a transistor tester and it shows nothing or a very low hfe (say 2), then you’ve made an error.

Hi,
Look at this circuit of yours.


If you follow the black wire from the collector of the transistor it loops all the way back to ground.
This means you have full supply across the LED array.

Tom... :slight_smile:

Hi,
I think this is what you are basically trying to do;

Can you post a link to your LED arrays, and/or a picture of them please?
What are you using for a 5V supply and do you have a DMM?

Thanks.. Tom.. :slight_smile: