5V LED strip which do not change color

Hi,
I am generally new to arduino programming. I was given the task of making an LED strip that needs to change color using an Arduino. (In this case I use Arduino Uno ATMEGA 328P).

The scheme I used for connecting everthing:


The differences between the scheme and what I connected is that instead of 12V, I put 5V directly on the arduino and ports red,green and blue that are connected to the arduino are different. In sheme it is 5,6,9 but I connected them in 3,5,6 .
For the LED strip, I use 5V 50cm RGB with 4 ports (R, G, B, 5V).Here is a link to the strip:

I read that MOSFETs should also be used, so I bought these on the professor's recommendation:
https://www.ad-electronic.hr/index.php/poluvodiči%20-%201085/tranzistori%20-%201086/irf9520-p-fet-100v-6,8a-60w-0,6r-to-2206291426-detalji
Since the tape uses 4 ports, which are R, G, B, 5V, and I don't know how to weld, I decided to connect it to the board. Here's a picture of what it looks like:


All the way to the right is that white cable that is connected to the breadboard is from strip and split into 4 ports as I said. The first red (left) wire is 5V, the green wire is G, the second red is R and the blue wire is B(written up on the strip).
When i connect the arduino to the computer the bar lights up white. I made the code so that instead of white it is only red and the color does not change (just for testing):


const int redPin = 3;     //it is also physically connected
const int greenPin = 5;   //it is also physically connected
const int bluePin = 6;   //it is also physically connected

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);

  analogWrite(redPin, 255);
  analogWrite(greenPin, 0);
  analogWrite(bluePin, 0);

  Serial.begin(9600);
  
}

void loop() {
}

When the code is sent to the arduino nothing changes(still white). I thought it was because maybe there is no other color but when you unplug one of the R,G,B ports the color changes. I use that code because I think this tape is analog. Any help or instructions on what to do next, I'm stuck and I don't know what to do next?

Make a drawing that shows the project completely. Do not half-draw something, then describe the invisible half. Not one single LED is visible on this post.

That is not a schematic, it is far from it. Please redo it with the correct connections and no instead ofs in the explanation. Also it helps if you show the complete picture. Schematics also label parts again missing. You talk about LEDs but where are they. Things need power and we know the Arduino is not a power supply so where does the power come from? Links to each of the components technical information is also requested.

I have no idea why the professor suggest a P Channel MOSFET? I would be using a N Channel logic level MOSFET configured like this:

Next LED color scheme is done using PWM channels (pins) and pin 5 is not a PWM pin.

Your code sample as written should be Red. Red 255 Green 0 and Blue 0. You need to understand how colors are generated. White for example is Red 255, Green 255 and Blue 255 and so it goes. Google Color Picker.

We work from schematics and not pictures, nobody can see exactly your wiring scheme from those pictures. I am guessing you have common Anode LEDs meaning the common anodes are tied to 5.0 volts and your cathodes are switched.

Ron


the far left with an arrow indicates that it is 5V

Did it in new replay. So LED strips of 5V can't he directly power on arduino? I know MOSFET should lower the voltage and amps if it is higher...?

If I now go to the store and want to buy N -FET, can i just buy any MOSFET, I can still buy TO-220? 2SK1420 N-FET 60V 25A 30W TO220(Tranzistori : 2SK1420 N-FET 60V 25A 30W TO220).
Now I know what happend. I get to the store and said TO220 N-MOSFET and for some reason he gave me this(I get 3 MOSFETs in small bag and recieve). Doesn't like ATMEGA 328p have 6 PWM ports : 3,5,6,9,10,11 ? So I can use any of that?

No, an Arduino cannot power a LED strip. Well a small strip, a few LEDs yes but while an Arduino can power small devices requiring low power it cannot really provide much current. You want/need an external 5.0 volt supply for your LEDs.

As drawn your MOSFETs have all the pins shorted? You need to understand how your board is configured.

I left you with a drawing (schematic) which included part numbers for the MOSFETs used. Again you want an N channel logic level MOSFET. I used FQP30N06L but you can use the N Channel Logic Level of your choice.

Ron

1 Like

Are you sure? They don't look shorted to me, perhaps I'm missing something.

Hi Perry, this is what I am seeing.

I highlighted using arrows. Maybe I am seeing this all wrong but each MOSFET seems to have their pins shorted? Again, maybe just me seeing what isn't there.

I am also not seeing any gate resistors like 10K gate to common or a series resistor on each gate to limit current at turn on?

Ron

1 Like


I circle you with blue color where pins are. So I'll change the P to N MOSFET tomorrow I guess, because we have a holiday today and I'll use your wiring sheme. As far as I can see, the difference is in the connection of the gate (G) with the resistor and ground and the color of the LED strip (if that means PART 1), while in my case only the color is connected. So I'll change that too. Correct me if I missed something or forget something. Tnx

1 Like

I see it as the MOSFETs are drawn there but connected with the black lines sloping down and left not shorted.

@roketa
Please clarify which is correct.

yours is correct @PerryBebbington

1 Like

When I look at it the MOSFETs are all plugged into the board on the same rows of pin sockets on the board. This is where I see source, gate and drain all shorted. The circled pin connections are fine.


The pins in the above image are shorted where they connect to the board.


The pins are not shorted.

It's about MOSFET orientation on your board. What happens if you measure resistance between source to gate to drain with your current setup? Where your black connections are, wire to wire?

Ron

1 Like

it's just about orientation because the program in which I made the sketch can't rotate things. In reality it looks like this other picture of yours


Colors:
Black - ground
Red - one of the pins in LED strip (R,G,B)
Blue - to arduino port 3 or 5 or 6

I dont know what do you mean by wire to wire? Where do you see it in sheme?

OK so you have the orientation as I show in the correct orientation image. That's what I was getting at and that's why most of us despise software like Fritzing. Don't worry about the wire to wire as it had to do with orientation. OK, so back to colors.

Earlier I mentioned a color picker and suggested knowing how colors are generated. We start with three colors, Red, Green and Blue. Each color used a number between 0 and 255. This is some Arduino sample code taken from an Arduino lesson:

/*
Adafruit Arduino - Lesson 3. RGB LED
*/
 
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
int brkPin = 8;
 
//uncomment this line if using a Common Anode LED
#define COMMON_ANODE
 
void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT); 
  pinMode(brkPin, INPUT); 
}
 
void loop()
{
setColor(255, 0, 0);  // red
  delay(2000);
  setColor(0, 255, 0);  // green
  delay(2000);
  setColor(0, 0, 255);  // blue
  delay(2000);
  setColor(255, 255, 0);  // yellow
  delay(2000);  
  setColor(255, 0, 255);  // purple
  delay(2000);
  setColor(0, 255, 255);  // aqua
  delay(2000);
  setColor(255, 255, 255); // white
  delay(2000);
  setColor(0, 0, 0); // black off
  delay(2000);
  setColor(255, 0, 0);  // red
  delay(1000);
  setColor(0, 255, 0);  // green
  delay(1000);
  setColor(0, 0, 255);  // blue
  delay(1000);
  setColor(255, 255, 0);  // yellow
  delay(1000);  
  setColor(255, 0, 255);  // purple
  delay(1000);
  setColor(0, 255, 255);  // aqua
  delay(1000);
  setColor(255, 255, 255); // white
  delay(1000);
  setColor(0, 0, 0); // black off
  delay(1000);  

}
 
void setColor(int red, int green, int blue)
{
  #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  #endif
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);  
}

I suggest you try this code using the wiring scheme I posted earlier. Also you want/need the resistors I mentioned. You want 10K Ohm each gate to ground and about a 220 Ohm resistor in series with each gate. Note in the code sample only 0 or 255 is used but that is only for the colors mentioned in the code.

Ron

Will do! Can you just tell me what is brkPin used for?

Now that you mention it I have no idea and it never shows up in the code? Yet they show it as an input pin. You know what? Just leave it out. I looked at a new version of the code found here and there is no mention of it. I loaded the code and ran it looking at the out pins on a scope. I never gave a thought to the brk pin. :slight_smile:

Ron

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.