Hello,
I'm trying to make a light strip with two PIR sensors. So far I have managed to make everything I wanted, but failed at the thing I would imagine would be most simple to do - controlling the LED's intensity. When the movement is detected I want the light to smoothly switch on and after a while when it checks for movement again fade it to zero.
Since I want to use the PWM output to control the 12V power supply I thought that using a transistor is the only option and out of the parts I have I chose to use BD140-16. I was initially planning on using a MOSFET, but I'm afraid I fried it ![]()
The problem that I currently have is that I can't switch off the LED completely and only when I physically unplug the 3rd pin the LEDs turn off. High/low output on the pin or any of the analog values only dim it, but the current is still flowing. I'm guessing I need to include a resistor along the way, but can't figure it out.
Tried googling all different LED set-ups with transistors and it looks like I'm doing the exact same thing as other people, but still get different results.
Another issue with the transistor is that it heats up a lot. I've seen some people soldering heat sinks to the back of the transistor, but maybe there's a better way to cut off the current completely when the movement is not detected for a longer time, let's say 5 minutes (a relay?)
Small disclaimer ... as a 35 yo this is my first contact with electronics and English is not my first language, so please speak slowly. ![]()
This is the code I'm using for testing the fading effect.
int LEDstrip = 3;
void setup()
{
pinMode(LEDstrip, OUTPUT);
}
void loop()
{
for(int i=0; i<255; i++)
{
analogWrite(LEDstrip, i);
delay(10);
}
digitalWrite(LEDstrip, HIGH);
delay(500);
for(int i=255; i>0; i--)
{
analogWrite(LEDstrip, i);
delay(10);
}
delay(500);
}
the 12v power supply comes from the top and the LED strip is on the left.
Cheers