RGB LED color changing

Hey people

I'm trying to get an rgb led to change color depending on how you connect different wires (the ones named silver in code).

const int silver_1 = 4; 
const int silver_2 = 7; 
const int silver_3 = 8; 
const int silver_4 = 9; 
const int silver_5 = 10; 
const int silver_6 = 11; 
const int silver_7 = 12; 

const int ledRed = 3; 
const int ledBlue = 5; 
const int ledGreen = 6; 

int silverState_1;
int silverState_2;
int silverState_3;
int silverState_4;
int silverState_5;
int silverState_6;
int silverState_7;

void setup() 
{
  Serial.begin(9600);
  pinMode(ledRed, OUTPUT); 
  pinMode(ledBlue, OUTPUT); 
  pinMode(ledGreen, OUTPUT); 
  
  pinMode(silver_1, INPUT);
  pinMode(silver_2, INPUT);
  pinMode(silver_3, INPUT);
  pinMode(silver_4, INPUT);
  pinMode(silver_5, INPUT);
  pinMode(silver_6, INPUT);
  pinMode(silver_7, INPUT);
}

void loop ()
{
  silverState_1 = digitalRead(silver_1);
  silverState_2 = digitalRead(silver_2);
  silverState_3 = digitalRead(silver_3);
  silverState_4 = digitalRead(silver_4);
  silverState_5 = digitalRead(silver_5);
  silverState_6 = digitalRead(silver_6);
  silverState_7 = digitalRead(silver_7);
  
  if (silverState_1 == HIGH)
  {
    // Red. 
    digitalWrite(ledRed, 255);
    digitalWrite(ledBlue, 0);
    digitalWrite(ledGreen, 0);
  }
  else if (silverState_2 == HIGH)
  {
    // Orange. 
    digitalWrite(ledRed, 255);
    digitalWrite(ledBlue, 0);
    digitalWrite(ledGreen, 165);
  }
  else if (silverState_3 == HIGH)
  {
    // Yellow. 
    digitalWrite(ledRed, 255);
    digitalWrite(ledBlue, 0);
    digitalWrite(ledGreen, 255);
  }
  else if (silverState_4 == HIGH)
  {
    // Green. 
    digitalWrite(ledRed, 0);
    digitalWrite(ledBlue, 0);
    digitalWrite(ledGreen, 128);
  }
   else if (silverState_5 == HIGH)
  {
    // Blue. 
    digitalWrite(ledRed, 0);
    digitalWrite(ledBlue, 255);
    digitalWrite(ledGreen, 0);
  }
   else if (silverState_6 == HIGH)
  {
    // Indigo. 
    digitalWrite(ledRed, 75);
    digitalWrite(ledBlue, 130);
    digitalWrite(ledGreen, 0);
  }
   else if (silverState_7 == HIGH)
  {
    // Purple. 
    digitalWrite(ledRed, 128);
    digitalWrite(ledBlue, 128);
    digitalWrite(ledGreen, 0);
  }
  else
  {
    // None (Black). 
    digitalWrite(ledRed, 0);
    digitalWrite(ledBlue, 0);
    digitalWrite(ledGreen, 0); 
  }
}

My problem is that some of the colors such as orange and indigo don't work.

I think that when one of the pins is set to 0 it means that the light is off and when it's set to some other number it's on.

Anyone know of a way to fix it?
Thanks in advance...

Edit:
I am working with the Arduino UNO and the rgb led is a common cathode. If that makes a difference.

You will have to implement PWM in order to control the color gradient. Have a look at Arduino Playground - RGBLEDPWM

So does that mean i can't do it without potentiometers?

digitalWrite() takes HIGH or LOW as argument, not a number. So it's either ON or OFF. To control how bright an LED is, you need to use the PWM pins and use analogWrite() which accepts a value between 0 to 255. Read that link that xaxxx gave you. Figure out what PWM is, which pins support PWM, and how to re-wire your circuit and re-write your program to do what you want it to do.

In place of :-

digitalWrite(ledRed, 75);
    digitalWrite(ledBlue, 130);
    digitalWrite(ledGreen, 0);

You need :-

analogWrite(ledRed, 75);
    analogWrite(ledBlue, 130);
    analogWrite(ledGreen, 0);

Providing that your ledRed, ledBlue and ledGreen pins are capable of PWM output, which on the Uno pin 3, 5 & 6 are.

Thanks for the help Grumpy_Mike

Unfortunately it didn't really work. I have three pins in 3, 5, 6 and they are all PWM.

I use 220 Ohm resistors if that makes a difference.

And i changed it to analogWrite.

Anything i can do to help you to help me?

Unfortunately it didn't really work

Can you be more precise, what happens and what did you expect to happen?

Can you be more precise, what happens and what did you expect to happen?

I tried changing the code as you said, and was hoping for the led to change to the right colors, such as the orange.

But the led is still lighting the same colors as before.

The orange is still just the red and green lighting together equally.

Just to make sure that nothing else is interfering, just write a simple sketch that sets the orange colour and then fades the red up and down.

digitalWrite() takes HIGH or LOW as argument, not a number. So it's either ON or OFF.

Whilst it's true that the second argument is interpreted as ON or OFF, digitalWrite follows the C convention that zero is OFF, and non-zero is ON, and so any value in the range 1...255 inclusive will be interpreted as ON.

But, as noted, this probably isn't what the OP wanted.

did u see this?