Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. int Led_R = 6;    
  2. int Led_G = 3;  
  3. int Led_B = 5;    
  4.  
  5. int Valor_R = 0;  
  6. int Valor_G = 0;  
  7. int Valor_B = 0;  
  8.  
  9. char Letra;      
  10.  
  11. void setup()
  12. {
  13.  
  14.   Serial.begin(9600);
  15.  
  16.   pinMode(Led_R, OUTPUT);
  17.   pinMode(Led_G, OUTPUT);
  18.   pinMode(Led_B, OUTPUT);
  19. }
  20.  
  21.  
  22. void loop()
  23. {  
  24.  
  25.   if (Serial.available() > 0)
  26.   {  
  27.    
  28.     Letra = Serial.read();
  29.    
  30.    
  31.     if (Letra == 'R'){
  32.       Valor_R = Serial.parseInt();
  33.     }
  34.     if (Letra == 'G'){
  35.       Valor_G = Serial.parseInt();
  36.     }
  37.     if (Letra == 'B'){
  38.       Valor_B = Serial.parseInt();
  39.    
  40.     }
  41.   }
  42.  
  43.   analogWrite(Led_R, Valor_R);
  44.   analogWrite(Led_G, Valor_G);
  45.   analogWrite(Led_B, Valor_B);
  46.      
  47. }