int pinR = 3;
int pinG = 5;
int pinB = 6;
int trigpin = 8;
int echopin = A0;

void setup() {
  // put your setup code here, to run once:
  pinMode(trigpin, OUTPUT);
  pinMode(echopin, INPUT);
  pinMode(pinR, OUTPUT);
  pinMode(pinG, OUTPUT);
  pinMode(pinB, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(trigpin, LOW);
  digitalWrite(trigpin, HIGH);

  int value = pulseIn(echopin, HIGH);

  digitalWrite(pinR, HIGH);
  digitalWrite(pinG, LOW);
  digitalWrite(pinB, LOW);
  delay(value);
  
  digitalWrite(pinG, HIGH);
  digitalWrite(pinR, LOW);
  digitalWrite(pinB, LOW);
  delay(value);

  digitalWrite(pinB, HIGH);
  digitalWrite(pinR, LOW);
  digitalWrite(pinG, LOW);
  delay(value);

}