Unsure of how to code MOSFET RGB LED setup

I'm new to arduino/electronics and right now am having a hard time figuring out how to turn on this RGB LED with this MOSFET setup:

Instead of a strip, I have a single RGB LED and have three transistors instead of one (one for each pin of the RGB LED).

I've tried running this code:

#define GatePinsev 7
#define GatePinsix 6
#define GatePinfive 5
int GateSignal = 0;

void setup () {
  pinMode (GatePinsev, OUTPUT);
}

void loop () {
  while ((GateSignal <0) || (GateSignal >1023)) {
    continue;
    
  }
analogWrite (GatePinsev, GateSignal);
}

to just try and turn on the LED, but nothing happens. I'm using pins 5,6,7 for each transistor and am pretty sure I connected everything correctly.
Any suggestions?

The variable gatesignal starts off at zero and there is nothing that changes it, so why would it ever get out of that while loop?

I have a single RGB LED

Any resistors in seriese with that LED?

Grumpy_Mike:
The variable gatesignal starts off at zero and there is nothing that changes it, so why would it ever get out of that while loop?
Any resistors in seriese with that LED?

Yeah I have 100 ohm resistors between the voltage source/LED and arduino/transistor.
I change the gatesignal but still nothing happens

I change the gatesignal but still nothing happens

Changed it to what?

When you change your code then post it again so we can see what you have done.

Yeah I have 100 ohm resistors between the voltage source/LED and arduino/transistor.

Words don't cut it in electronics. That is a very vague description. Can you sketch the schematic with pen and paper and post a photograph of it please? With component values.

While we are at it a IRF530 needs 10V to fully turn it on and an Arduino can only supply a 5V gate signal. You need a logic level FET

Grumpy_Mike:
Changed it to what?

When you change your code then post it again so we can see what you have done.
Words don't cut it in electronics. That is a very vague description. Can you sketch the schematic with pen and paper and post a photograph of it please? With component values.

While we are at it a IRF530 needs 10V to fully turn it on and an Arduino can only supply a 5V gate signal. You need a logic level FET

Okay here are the two ways I changed the GateSignal value:

#define GatePinsev 7
#define GatePinsix 6
#define GatePinfive 5
int GateSignal = 500;

void setup () {
  pinMode (GatePinsev, OUTPUT);
}

void loop () {
  while ((GateSignal <0) || (GateSignal >1023)) {
    continue;
    
  }
analogWrite (GatePinsev, GateSignal);
}
#define GatePinsev 7
#define GatePinsix 6
#define GatePinfive 5
int GateSignal = 1060;

void setup () {
  pinMode (GatePinsev, OUTPUT);
}

void loop () {
  while ((GateSignal <0) || (GateSignal >1023)) {
    continue;
    
  }
analogWrite (GatePinsev, GateSignal);
}

I've attached my schematic. Hopefully it is clear.

Sorry I realize now my transistor is IRL540NPBF

The second one stands no chance of working because as I said before nothing in that while loop changes the GateSignal variable.

The second one stands more chance because it will miss out the while loop all together. Now you say:-

I'm using pins 5,6,7 for each transistor

For an analogue output ( PWM ) you must use a PWM capable pin. To this end pin 7 is not a PWM capable pin and so you can't use it to dim a FET. The pins you can use are marked with a ~.
Note that the analogue output command only takes values from 0 to 255, after that it wraps round, that means a value of 256 gives the same result as 0.

Also like I said that FET needs 10V but you might get something to show with only 5V, but don't think it will be adequate.

IMG_1825.jpg

Grumpy_Mike:
Also like I said that FET needs 10V but you might get something to show with only 5V, but don't think it will be adequate.

Hmmm. He seems to have corrected the FET to the IRL540, so that should work.

But the 100 Ohm in the common anode would not be appropriate if more than one colour is to be shown at the one time. There needs to be a resistor in series with each cathode. Now 12 V at 100 Ohm; 100 mA is too much for a single LED. If on the other hand, you really do mean a common anode LED strip, then those resistors are built in.

You need a resistor in each cathode.

Paul__B:
IMG_1825.jpg

Hmmm. He seems to have corrected the FET to the IRL540, so that should work.

But the 100 Ohm in the common anode would not be appropriate if more than one colour is to be shown at the one time. There needs to be a resistor in series with each cathode. Now 12 V at 100 Ohm; 100 mA is too much for a single LED. If on the other hand, you really do mean a common anode LED strip, then those resistors are built in.

Okay I added 100 ohm resistors in series with each cathode and replcaed the 100 ohm resistor at the anode with a 1000 ohm one. This is a single RGB LED.
I really just want to see if I can turn on the LED right now with this setup and it still won't. This is frustrating :confused:

and replcaed the 100 ohm resistor at the anode with a 1000 ohm one

No.
The anode has to be connected directly to 12V.

This is frustrating

Indeed it is, you show no sign of following any advice.
What about your software have you fixed that yet?

Post a photograph of your setup. What sort of LED do you have? Is it a power LED?