Need help with RGB led and random colors sketch

I am really new to coding and Arduino. I am trying to get an led to blink random colors it is doing that for the most part but it sometimes just turns the led off for a delay cycle and i have no idea why. could some one look at my code and tell me if i am just missing something easy please? I have a few things in there commented out about using a button but it is not needed for what i am doing(and i still have not figured out why it does not want to work).

int Rval = A1;//sets pin 1 to red leg of led
int Gval = A2;//sets pin 2 to green leg of led
int Bval = A3;//sets pin 3 to blue leg of led
int randomNumberR;// name for random number on red leg of led
int randomNumberG;// name for random number og green leg of led
int randomNumberB;// name for random number on blue leg of led
//int button = 7;//sets button on pin 7
//int buttonState = 0;//

void setup() {

Serial.begin(9600);
//pinMode(button, INPUT);//sets pin 7 as input
pinMode(Rval, OUTPUT);//sets pin 1 as output
pinMode(Gval, OUTPUT);//sets pin 2 as output
pinMode(Bval, OUTPUT);//sets pin 3 as output

}

void loop()
{
//buttonState = digitalRead(button); //checks if button was pressed
//if (digitalRead(button) == HIGH);

int randomNumberR = random(20,200);
int randomNumberG = random(20,200);
int randomNumberB = random(20,200);

analogWrite(Rval, randomNumberR);
analogWrite(Gval, randomNumberG);
analogWrite(Bval, randomNumberB);
delay(1000);
Serial.println(randomNumberR);
Serial.println(randomNumberG);
Serial.println(randomNumberB);

I'm new to all this as well. However, I have spotted a couple of things that are wrong.

The first is probably a cut & paste error where you're missing the closing } of your loop().

The other is that you declared randomNumberR, G and B at the beginning of the sketch and then again inside the loop(). No need for the "int" in front of those inside the loop().

Will that fix your issues? Maybe.

what board are you using?

int Rval = A1;//sets pin 1 to red leg of led
int Gval = A2;//sets pin 2 to green leg of led
int Bval = A3;//sets pin 3 to blue leg of led

an UNO?

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

You are conflating the Analog INPUT designated pins as 'pins to use for analogWrite'. They have nothing to do with each other.

Change your LED pins to PWM capable pins (might have a ~ next to them on the board) and it will work.

As it is, when you random into a value too low to count as HIGH, nothing happens because your analogWrite is effectively digitalWrite LOW.

yes the board i am using is an UNO.

I will switch the pins over to PWM. i have been reading a bunch about programming for the Arduino and had not yet seen anything that told me that analogWrite was not tied to the analog pins. Thanks for pointing that out so many things make a bunch more sense to me now. Man i feel dumb for not getting that just from the example programs that i have read through trying to figure out how they work.

mikeoliver2014:
had not yet seen anything that told me that analogWrite was not tied to the analog pins.

You should go through the stuff on this page. Arduino Reference - Arduino Reference. If you'll look at the ref for analogWrite you'll find that it tells right there what pins it works on.