int AredPin= 8; // blue int AgreenPin = 10; //redish pink int AbluePin = 9; //yellow int BredPin= 4; // blue int BgreenPin = 3; //redish pink int BbluePin = 2; //yellow int photoTran = A1; int reading = 0; char dato; void setup() { // put your setup code here, to run once: pinMode(AredPin, OUTPUT); pinMode(AgreenPin, OUTPUT); pinMode(AbluePin, OUTPUT); pinMode(BredPin, OUTPUT); pinMode(BgreenPin, OUTPUT); pinMode(BbluePin, OUTPUT); Serial.begin(9600); digitalWrite(AredPin, HIGH); digitalWrite(AgreenPin, HIGH); digitalWrite(AbluePin, HIGH); digitalWrite(BredPin, HIGH); digitalWrite(BgreenPin, HIGH); digitalWrite(BbluePin, HIGH); } void loop() { // put your main code here, to run repeatedly: if (Serial.available()) { dato=Serial.read(); Serial.print(dato); } if(dato=='R') { AsetColor(255, 0, 0); BsetColor(255, 0, 0); } if(dato=='G') { AsetColor(0, 255, 0); BsetColor(0, 255, 0); } if(dato=='B') { AsetColor(0, 0, 255); BsetColor(0, 0, 255); } if(dato=='O') { AsetColor(0, 0, 0); BsetColor(0, 0, 0); } if(dato=='W') { AsetColor(255, 255, 255); BsetColor(255, 255, 255); } if(dato=='P') { reading = analogRead(photoTran); Serial.println(reading); delay(100); if (reading<600){ AsetColor(255, 255, 255); BsetColor(255, 255, 255); } else { AsetColor(0, 0, 0); BsetColor(0, 0, 0); } } } void AsetColor(int AredValue, int AgreenValue, int AblueValue) { analogWrite(AredPin, 255-AredValue); analogWrite(AgreenPin, 255-AgreenValue); analogWrite(AbluePin, 255-AblueValue); } void BsetColor(int BredValue, int BgreenValue, int BblueValue) { analogWrite(BredPin, 255-BredValue); analogWrite(BgreenPin, 255-BgreenValue); analogWrite(BbluePin, 255-BblueValue); }