Advertisement
juberth

Untitled

Sep 5th, 2013
1,256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #define PR A0 n puerto analogo (A0)
  2. #define PG A1
  3. #define PB A2
  4. int rojo = 11;
  5. int verde = 10;
  6. int azul = 9;
  7.  
  8.  
  9. void setup ()
  10. {
  11.  
  12.   pinMode (rojo, OUTPUT);
  13.   pinMode (verde, OUTPUT);
  14.   pinMode (azul, OUTPUT);
  15.  
  16.   pinMode (PR, INPUT);
  17.   pinMode (PG, INPUT);
  18.   pinMode (PB, INPUT);
  19.   Serial.begin (9600);
  20. }
  21.  
  22. void loop ()
  23. {
  24.   int R = analogRead(PR);
  25.   int i = map(R,0,1023,0,255);
  26.  
  27.   int G = analogRead(PG);
  28.   int i1 = map(G,0,1023,0,255);
  29.  
  30.   int B = analogRead(PB);
  31.   int i2 = map(B,0,1023,0,255);
  32.  
  33.   analogWrite (azul,i2);
  34.   analogWrite (rojo,i);
  35.   analogWrite (verde,i1);
  36.  
  37.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement