Potentiometer value either 1 or 0

So I have been dealing with an annoying aspect of my project. I am building an RGB color picker that uses three potentiometers to control the amount of red, green, and blue in an RGB LED. The issue is that the R and the G potentiometer work just fine. The G potentiometer, however, turns the amount of green all the way up to 255 if it is turned more than halfway through, otherwise there is no color. I've tried switching the analog pin, I've tried putting it on a different board, I've tried new potentiometers, and nothing has worked. I could really appreciate some help on this. Attached below is a link to a video demonstration of what I am talking about if you are confused. The green potentiometer is hooked up to analog pin 1. The code is also attached but I doubt there are any issues with that.

Any help would be appreciated. Thanks!

https://drive.google.com/file/d/1r1UrXgcgQ1mXr7XCKmuXnhMZo7lAT3q_/view?usp=sharing

int rPot=0;
int gPot=1;
int bPot=2; 
void setup() {
  pinMode(rPot, INPUT);
  pinMode(gPot, INPUT);
  pinMode(bPot, INPUT);
  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(gPot));
  analogWrite(6, map(analogRead(rPot), 0, 1023, 255, 0));
  analogWrite(4, map(analogRead(gPot), 0, 1023, 255, 0));
  analogWrite(3, map(analogRead(bPot), 0, 1023, 255, 0));
}

Assume you are using an UNO. PWM analogWrite() output pins are 3, 5, 6, 9, 10, and 11.

These lines are not needed. pinMode(rPot, INPUT); pinMode(gPot, INPUT); pinMode(bPot, INPUT);

Make sure your Pots are linear.

Although it's probably not the cause of your problem, it's advisable to use the Ax (A0 etc) numbers.

analogRead is clever enough and will use the analog pins if you pass 0, 1, 2. pinMode does not know that you're referring to the analog pins and with your setup code will happily set the digital pins 0, 1 and 2 to input.

The legend on the Uno PCB tells you which digital pins can be used for PWM.
They are marked with a ‘~’ symbol by the pin number.

These pins were also listed by Larryd.
If they aren’t on that list, then they don’t support PWM.

Hi, You have a Serial.print statement, what does the IDE monitor show for your pot positions as you turn them?

Also I think you need to pinMode your outputs too.

Try this edit of your code;

int rPotPin = A0;
int gPotPin = A1;
int bPotPin = A2;
int rLEDPin = 6;
int gLEDPin = 5;
int bLEDPin = 3;
int rVal = 0;
int gVal = 0;
int bVal = 0;


void setup() {
  pinMode(rLEDPin, OUTPUT);
  pinMode(gLEDPin, OUTPUT);
  pinMode(bLEDPin, OUTPUT);
  Serial.begin(9600);
}


void loop() {
  rVal = analogRead(rPotPin);
  gVal = analogRead(gPotPin);
  bVal = analogRead(bPotPin);
  Serial.print("rVal =\t");
  Serial.print(rVal);
  Serial.print("\tgVal =\t");
  Serial.print(gVal);
  Serial.print("\tbVal =\t");
  Serial.println(bVal);


  analogWrite(rLEDPin, map(rVal, 0, 1023, 255, 0));
  analogWrite(gLEDPin, map(gVal, 0, 1023, 255, 0));
  analogWrite(bLEDPin, map(bVal, 0, 1023, 255, 0));
  delay(100);
}

I prefer to get all my analog inputs stored in variables before using them, as this takes a snap shot of the inputs for the code to work on.

I have assigned pins 3, 5, 6 as your PWM output pins.

Tom.. :)