jueves, 24 de septiembre de 2015

LABORATORIO # 6

DESCRIPCIÓN DEL LABORATORIO:

En este laboratorio Controlaremos un LED RGB desde el Arduino, vía PWM con 3 potenciometros, uno para cada color. 


MATERIALES:

- Protoboard
- Arduino
- 3 Resistencias
- Cable UTP
- Led RGB
- 3 Potenciometros



DIAGRAMA:




ESQUEMA:






FOTOS MONTAJE:










VIDEO:






CODIGO:



Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  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. void setup ()
  8. {
  9.   pinMode (rojo, OUTPUT);
  10.   pinMode (verde, OUTPUT);
  11.   pinMode (azul, OUTPUT);
  12.   pinMode (PR, INPUT);
  13.   pinMode (PG, INPUT);
  14.   pinMode (PB, INPUT);
  15.   Serial.begin (9600);
  16. }
  17. void loop ()
  18. {
  19.   int R = analogRead(PR);
  20.   int i = map(R,0,1023,0,255);
  21.   int G = analogRead(PG);
  22.   int i1 = map(G,0,1023,0,255);
  23.   int B = analogRead(PB);
  24.   int i2 = map(B,0,1023,0,255);
  25.   analogWrite (azul,i2);
  26.   analogWrite (rojo,i);
  27.   analogWrite (verde,i1);
  28.  }

No hay comentarios:

Publicar un comentario