About This Project
The objective of this project is to control an RGB LED by turning it on, off, and fading it from a remote location using an IR remote control.
The TSOP 1738 is an infrared receiver containing “a PIN diode and a pre amplifier which are embedded into a single package.” The output operates as active low, outputting +5V when idle. When exposed to IR waves at a center frequency of 38 kHz from a source, its output goes low.
Components Required
- Arduino UNO
- RGB Diffused Common Cathode
- IR receiver
- Breadboard
- Resistor 1K Ohm
Code Of Project
#include <IRremote.h>
int red = 11;
int green = 10;
int blue = 9;
int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume();
if (results.value == 0xFD08F7) {
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}
if (results.value == 0xFD8877) {
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
}
if (results.value == 0xFD48B7) {
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
}
if (results.value == 0xFD28D7) {
analogWrite(11, 255);
analogWrite(9, 255);
analogWrite(10, 0);
}
if (results.value == 0xFDA857) {
analogWrite(11, 0);
analogWrite(9, 255);
analogWrite(10, 255);
}
}
delay(100);
}