led light strip

i have a plan to set up the following circuit(the circuit diagram is in the png) for a light strip and control it with the arduino i was wondering if anyone could tell me if my code is right.

int REDLED = 3;
int GREENLED = 5;
int BLUELED = 6;

int i = 0;
//black to red to black to green to black to blue to black "repeat"
int red = 0;
int green = 0;
int blue = 0;

void setup()
{
 Serial.begin(9600);

 pinMode(REDLED, OUTPUT);
 pinMode(GREENLED, OUTPUT);
 pinMode(BLUELED, OUTPUT);

}

void loop()
{
 i = 0;
        //0,0,0
        Serial.print(red);Serial.print(',');Serial.print(green);Serial.print(',');Serial.println(blue);
 for (i = 0; i <= 255; i++)//black to red
 {
 red = i;
 analogWrite(REDLED, red);
 Serial.println(red);
 }
        //255,0,0
        Serial.print(red);Serial.print(',');Serial.print(green);Serial.print(',');Serial.println(blue);
 for (i = 255; i >= 0; i--)//red to black
 {
 red = i;
 analogWrite(REDLED, red);
 Serial.println(red);
 }
        //0,0,0
        Serial.print(red);Serial.print(',');Serial.print(green);Serial.print(',');Serial.println(blue);
 for (i = 0; i <= 255; i++)//black to green
 {
 green = i;
 analogWrite(GREENLED, green);
 Serial.println(green);
 }
        //0,255,0
        Serial.print(red);Serial.print(',');Serial.print(green);Serial.print(',');Serial.println(blue);
 for (i = 255; i >= 0; i--)//green to black
 {
 green = i;
 analogWrite(GREENLED, green);
 Serial.println(green);
 }
        //0,0,0
        Serial.print(red);Serial.print(',');Serial.print(green);Serial.print(',');Serial.println(blue);
 for (i = 0; i <= 255; i++)//black to blue
 {
 blue = i;
 analogWrite(BLUELED, blue);
 Serial.println(blue);
 }
        //0,0,255
        Serial.print(red);Serial.print(',');Serial.print(green);Serial.print(',');Serial.println(blue);
 for (i = 255; i >= 0; i--)//blue to black
 {
 blue = i;
 analogWrite(BLUELED, blue);
 Serial.println(blue);
 }
        //0,0,0
        Serial.print(red);Serial.print(',');Serial.print(green);Serial.print(',');Serial.println(blue);
}

the transistors are: http://www.ti.com/product/CSD18502KCS?keyMatch=csd18502kcs&tisearch=Search-EN-Products
the lights are: http://www.amazon.com/SUPERNIGHT-Waterproof-300LEDs-Changing-Flexible/dp/B00DTOAWZ2/ref=pd_bxgy_hi_img_y
12v power: 12 volt rail off a 430w atx psu (12volt, 32amp)
i am using the arduino uno

What were your results when you tried?

You have missed the ground off your 12V supply. You have no resistors in the base of those transistors.

As you do not say what you want the code to do it is impossible to say if it is right. But the red = i and then using red in the analogue write is silly, why not just use i in the analogue write? Same for the other two colours.

You never seen to set the outputs low except in the fade up. You are using a Serial print as a delay!

i have built this a while back and i didnt use resistors. im using a different code now though. if black is off then it should fade black to red to black to green to black to blue to black. and im just increment the value of the pin. "You have missed the ground off your 12V supply" should i have the connected to the ground on the arduino along with the transistors.

i have yet to get the materials yet i would like to make sure i can do before i buy the suff thats why i am using the serial print to check to make sure the values were incrementing correctly.

You always need a resistor in the base of a transistor. If not you could damage the arduino. You need to connect all grounds together. You never put a colour to black AFTER you finish faiding it up.

Your right i don't have it fading up then going to back it fades from black to a color and the fades down to back. what resistor should i use and where does it connect.

i added a new diagram with the common ground

They are not transistors they are power FETs. Use a 120 to 330 ohm resistor in the gate of each FET.

Your new diagram does not reflect the pin out of the FET you will be using. The gate is pin 1 the drain pin 2 and the source pin 3.

the new diagram was to show the power supply ground

y would it harm the arduino if there is no resistor the current is running to the mosfet not to the arduino?

The current is running from the arduino to the FET. You would exceed the maximum ammount of current the Arduino can safely supply.

im new at this i dont understand y would be it unsafe wont the arduino supply what the arduino supplys? y would it exceed wouldnt i still just give off 5 volts? what kind of power output is does the pwm give off

PWM is just another 0-5V output, same as any other digital output.

yes so y would i need a resistor

kmtompkins: yes so y would i need a resistor

Yes.

You seem to be having trouble with your keyboard, it keeps missing the "ou" after yOU have typed a "y"

kmtompkins: what kind of power output is does the pwm give off

As with any other Arduino pin, you must limit the current you draw to about 20 mA. That is the limit of the Arduino.

The best analogy I can come up with at this time if night, is that you do not plug five electric radiators into a power board in your home and plug the power board into a power outlet.

Or do you? :astonished:

well it is y as in why

kmtompkins: well it is y as in why

So why do you use this abbreviation that anyone over the age of 20 is not going to understand? This is not a text message, we don't charge by the letter, it only pisses people off.

and why did this person do it with and without resistors whats the difference https://learn.adafruit.com/rgb-led-strips/usage

kmtompkins: and why did this person do it with and without resistors whats the difference https://learn.adafruit.com/rgb-led-strips/usage

Because they were poor designers and forgot that a FET's gate looks like a short circuit when switching it on. You must limit the current out of the Arduino's pin.

That web side does use resistors on the transistor version of the circuit.