Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**Proyecto**
- *Univrsidad Santiago de Cali
- *Programacion en sistemas embebidos
- *Nicolas Roman Buitrago
- *Laboratorio 5: controlar un LED RGB, con una interfaz grafica
- *que controla la intencidad de cada color
- */
- int ledR = 3;
- int ledG = 5;
- int ledB = 6;
- void setup() {
- Serial.begin(9600);
- pinMode(ledR, OUTPUT);
- pinMode(ledG, OUTPUT);
- pinMode(ledB, OUTPUT);
- }
- void loop() {
- if(Serial.available() > 0){
- char color = Serial.read();
- int valor = Serial.parseInt();
- Serial.print(valor);
- if(color == 'R'){
- encender(ledR,valor);
- }
- if(color == 'G'){
- encender(ledG,valor);
- }
- if(color == 'B'){
- encender(ledB,valor);
- }
- }
- }
- /************FUNCIONES****************/
- void encender (int led, int valor){
- analogWrite(led,valor);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement