int Rpin = 3;
int Gpin = 5;
int Bpin = 6;

int portR = A0;
int portG = A1;
int portB = A2;


void setup() {
  // put your setup code here, to run once:
  pinMode(Rpin, OUTPUT);
  pinMode(Gpin, OUTPUT);
  pinMode(Bpin, OUTPUT);
  pinMode(portR, INPUT);
  pinMode(portG, INPUT);
  pinMode(portB, INPUT);

}
int result(int pins){
  return map(analogRead(pins),0,1023,0,255);
}

void loop() {
  // put your main code here, to run repeatedly:
  analogWrite(Rpin,result(portR));
    analogWrite(Gpin,result(portG));
  analogWrite(Bpin,result(portB));

}