I have a simple white LED strip that I've had properly wired and working with code in the past. I went to reconfigure my board and can't get the strip running again. I have a photo of the wiring and the code I'm running. I'm tried it with even simple code to be sure that wasn't it - to no avail. Fairly sure I'm missing something in the wiring - any help would be much appreciated!
Claudia
int ledPin = 3; // back strip connected to PWN pin 5
int FADESPEED = 20; // make this higher to slow down
unsigned long previousMillis = 0; // last time update
long interval = 8000; // interval at which to do something (milliseconds)
boolean fadeIn = true;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// fade in from min to max in increments of 5 points:
//analogWrite(ledPin, 255);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
fade();
}
}
void fade(){
Serial.print("called fade, and fadein is ");
Serial.println(fadeIn);
if (fadeIn == true){
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(FADESPEED);
}
fadeIn = false;
}
else if (fadeIn == false){
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(FADESPEED);
}
fadeIn = true;
}
}
Yes - that's exactly what I'm trying to do - and even more frustratingly, I had it working. I've tried this exact setup with a regular LED, which of course does not require that much voltage, and that works. My only guess is that somehow I'm not getting enough power to the strip but I don't know what would have changed and I'm matching the setup of other diagrams I've found on the web.
It is a transistor - specifically N-Channel MOSFET 60V 30A. Sparkfun page is:
Still agonizing over this - help is much appreciated!
Claudia
Your image does not seem to match the bildr.org linked from the Sparkfun page. You seem to be trying to power the LED strip with 5V from the arduino, thankfully the forward voltage is to high or something else is wrong or you would probably overload/blow the arduino regulator.
thanks for your reply Riva - but I'm not sure I follow. are you suggesting that I need to use external power to power the LED strip? as i said - i've had this working by powering it from the 5v on the arduino. my understanding is that the transistor up-converts the power to be enough for the strip. that said - i'm unclear how the board could be affected by trying to power the strip from the 5v, as there is no external power coming in?
cbernett:
thanks for your reply Riva - but I'm not sure I follow. are you suggesting that I need to use external power to power the LED strip?
Yes
as i said - i've had this working by powering it from the 5v on the arduino.
More likely you powered it from a 9-12V power supply that was also powering the arduino through the jack connector.
my understanding is that the transistor up-converts the power to be enough for the strip.
The MOSFET is just a switch that allows a low voltage (3-5V) to switch on/off a higher voltage (up to 60V for this particular MOSFET). It does not up-convert 5V to become 12V.
that said - i'm unclear how the board could be affected by trying to power the strip from the 5v, as there is no external power coming in?
The 5V pin on the arduino will only supply a small amount of current and if you try and draw to much then something on the board (or your PC if it's powering the arduino over USB) could be damaged.
ahhh - thank you for this, success! and you're right - i switched the 12v wire from the LED strip to the Vin and it works. that said (and I should know this) but I'm not clear on the difference between the 5v and Vin pins and why one works but the other doesn't. Also - is it a bad idea to be using the Vin pin at all and should just switch to external power?
cbernett:
ahhh - thank you for this, success! and you're right - i switched the 12v wire from the LED strip to the Vin and it works. that said (and I should know this) but I'm not clear on the difference between the 5v and Vin pins and why one works but the other doesn't.
Vin is the unregulated voltage applied to the power jack on the arduino so if your using a 12V power supply it will be 12V. 5V as it's name implies is the output of the arduinos 5 volt regulator.
Also - is it a bad idea to be using the Vin pin at all and should just switch to external power?
A million dollar question that I'm sure other have views on but I personally always try to derive the power for >5V loads from the power source prior to it being connected to the arduino power socket. Routing a load through the arduino could cause extra heat build-up or damage to the PCB copper tracks.