Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

RGB Arduino uno r3

char p;

#include <IRremote.h>


IRrecv Yenuka(A2);
decode_results results;

#define redPin 6

#define greenPin 3

#define bluePin 5
void setup() {


   digitalWrite(6,HIGH);
   
    digitalWrite(3,HIGH);
   
    digitalWrite(5,HIGH);


  Serial.begin(9600);
  Yenuka.enableIRIn();

 
  pinMode(redPin, OUTPUT);

  pinMode(greenPin, OUTPUT);

  pinMode(bluePin, OUTPUT);

}

void loop() {

if (Yenuka.decode(&results)) {
    Serial.println(results.value, DEC);
    Yenuka.resume();
  }
  delay(100);

  long val = results.value;

    if (Yenuka.decode(&results)) {
    Serial.println(results.value, DEC);
    Yenuka.resume();
  }
 
if (val ==62855) {
    digitalWrite(6,LOW);//red color
     
    
  }
  if (val == 62791) {
 digitalWrite(3,LOW);//green color
   
  }
    if (val == 62919) {
 digitalWrite(5,LOW);//blue color
   
  }
    if (val == 62759) {//cyan
 digitalWrite(3,LOW);
   
    digitalWrite(5,LOW);
   
  }
      if (val == 62887) {//megenta
 digitalWrite(6,LOW);
   
    digitalWrite(5,LOW);
   
  }
       if (val == 62823) {//Yellow
 digitalWrite(6,LOW);
   
    digitalWrite(3,LOW);
   
  }
       if (val == 62951) {//White
 digitalWrite(6,LOW);
   
    digitalWrite(3,LOW);
 
    digitalWrite(5,LOW);
 
  }
  if (val == 50664) {//off
 digitalWrite(6,HIGH);
   
    digitalWrite(3,HIGH);
   
    digitalWrite(5,HIGH);
 
  }

if(Serial.available()){
  p = Serial.read();
  Serial.println(p);
}
 
if(p =='n'){            
 digitalWrite(6,HIGH);
   
    digitalWrite(3,HIGH);
   
    digitalWrite(5,HIGH);
 



}
 
else if(p == 'w'){    
 

 digitalWrite(6,LOW);
   
    digitalWrite(3,LOW);
 
    digitalWrite(5,LOW);


}
else if(p == 'r'){    
 

 digitalWrite(6,LOW);//red color


}
else if(p == 'g'){    
 

digitalWrite(3,LOW);//green color


}
 else if(p == 'b'){    
 

 digitalWrite(5,LOW);//blue color


}
 else if(p == 'c'){    
 

 digitalWrite(3,LOW);
   
    digitalWrite(5,LOW);


}
 else if(p == 'm'){    
 
 digitalWrite(6,LOW);
   
    digitalWrite(5,LOW);



}
 else if(p == 'y'){    
 
 digitalWrite(6,LOW);
   
    digitalWrite(3,LOW);



}

delay(100);
}
 
PREVIOUS NEXT
Tagged: #RGB #Arduino #uno
ADD COMMENT
Topic
Name
4+3 =