/*************************************************************************/
const int redPin = 11;  // R petal on RGB LED module connected to digital pin 11 
const int greenPin = 10;  // G petal on RGB LED module connected to digital pin 10 
const int bluePin = 9;  // B petal on RGB LED module connected to digital pin 9 
/**********************************************************/
const int xPin = A0;  //the VRX attach to
const int yPin = A1;  //the VRY attach to
const int swPin = 12;  //the SW attach to
/**************************************************************************/
void setup()
{ 
  pinMode(redPin, OUTPUT); // sets the redPin to be an output 
  pinMode(greenPin, OUTPUT); // sets the greenPin to be an output 
  pinMode(bluePin, OUTPUT); // sets the bluePin to be an output 

  pinMode(swPin, INPUT_PULLUP);  //set the SW pin to INPUT_PULLUP
  Serial.begin(9600);
}    
/***************************************************************************/
void loop()  // run over and over again  
{    
  const int xPos = analogRead(xPin);
  const int yPos = analogRead(yPin);
  const int zState = digitalRead(swPin);

  const int redLevel = map(xPos, 0, 1023, 0, 255);
  const int greenLevel = map(yPos, 0, 1023, 0, 255);
  const int blueLevel = map(-yPos, 0, 1023, 0, 255);

  Serial.print("X: ");
  Serial.print(xPos);  // print the value of VRX in DEC
  Serial.print("|Y: ");
  Serial.print(yPos);  // print the value of VRX in DEC
  Serial.print("|Z: ");
  Serial.println(zState);   // print the value of SW
  // delay(50);

  // // Basic colors:  
  color(redLevel, greenLevel, blueLevel); // turn the RGB LED red 
}     
/******************************************************/
void color (unsigned char red, unsigned char green, unsigned char blue)// the color generating function  
{    
  analogWrite(redPin, red);   
  analogWrite(greenPin, green); 
  analogWrite(bluePin, blue); 
}
/******************************************************/


$abcdeabcde151015202530fghijfghij