distancia2 int = 0;
int analogPin0 = 0;
int analogPin2 = 1;
int rojo = 11;
int azul = 10;
int verde = 9;
azul2 int = 5;
int red2 = 6;
green2 de int = 3;
Float redVal = 0.;
Float blueVal = 0.;
flotador greenVal = 0.;
Float red2Val = 0.;
Float blue2Val = 0.;
Float green2Val = 0.;
void setup() {}
pinMode (analogPin0, entrada);
pinMode (analogPin2, entrada);
pinMode(red,OUTPUT);
pinMode(blue,OUTPUT);
pinMode(green,OUTPUT);
pinMode(red2,OUTPUT);
pinMode(blue2,OUTPUT);
pinMode(green2,OUTPUT);
Serial.Begin(9600); Configurar la comunicación serial.
}
void loop() {}
distancia = analogRead(analogPin0);
distancia2. = analogRead(analogPin2);
Serial.Print ("valor de la distancia:");
Serial.Print ("distancia valor 2:");
Serial.println(Distance);
Serial.println(distance2);
redInt int = 0;
int blueInt = 0;
int greenInt = 0;
int red2Int = 0;
int blue2Int = 0;
int green2Int = 0;
int fadevalue = 0;
Si (distancia < = 350 & & distancia > = 0) {}
blueVal = (350 - distancia) * (255/350.);
blueInt = (int) blueVal;
}
Else {}
digitalWrite(blue,LOW);
}
Si (distancia < = 300 & & distancia > = 50) {}
greenVal = (distancia - 50.) * (255/250.);
greenInt = (int) greenVal;
}
else if (distancia > 300 & & distancia < = 500) {}
greenVal = (500 - distancia) * (255/200.);
greenInt = (int) greenVal;
}
Else {}
digitalWrite (verde, baja);
}
Si (distancia < = 650 & & distancia > = 300) {}
redVal = (distancia - 300). * (255/350.);
redInt = (int) redVal;
}
Else {}
digitalWrite (rojo, baja);
}
Si (distancia2 < = 350 & & distancia2 > = 0) {}
blue2Val = (350 - distancia2.) * (255/350.);
blue2Int = (int) blue2Val;
}
Else {}
digitalWrite(blue2,LOW);
}
Si (distancia2 < = 300 & & distancia2 > = 50) {}
green2Val = (distancia2. - 50.) * (255/250.);
green2Int = (int) green2Val;
}
else if (distancia2 > 300 & & distancia2 < = 500) {}
green2Val = (500 - distancia2.) * (255/200.);
green2Int = (int) green2Val;
}
Else {}
digitalWrite (green2, LOW);
}
Si (distancia2 < = 650 & & distancia2 > = 300) {}
red2Val = (distancia2. - 300.) * (255/350.);
red2Int = (int) red2Val;
}
Else {}
digitalWrite (red2, LOW);
}
analogWrite (rojo, redInt);
analogWrite (blue, blueInt);
analogWrite (verde, greenInt);
analogWrite (red2, red2Int);
analogWrite (azul2, blue2Int);
analogWrite (green2, green2Int);
}