0% found this document useful (0 votes)
44 views5 pages

Experiment No. 12: IR Remote Control Connection:: Microprocessor

This document describes an Arduino coding experiment to control LED colors using an IR remote control. The code initializes an IR receiver to decode signals and sets up RGB LED pins. It includes a switch statement to set different colors - red, green, blue, yellow, purple, aqua, white, off - based on the decoded IR remote button press value, by calling a setColor function to write analog values to the LED pins.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views5 pages

Experiment No. 12: IR Remote Control Connection:: Microprocessor

This document describes an Arduino coding experiment to control LED colors using an IR remote control. The code initializes an IR receiver to decode signals and sets up RGB LED pins. It includes a switch statement to set different colors - red, green, blue, yellow, purple, aqua, white, off - based on the decoded IR remote button press value, by calling a setColor function to write analog values to the LED pins.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MICROPROCESSOR

EXPERIMENT NO. 12 : IR Remote Control


Connection:

Coding:
#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
int RedPin = 9;
int GreenPin = 10;
int BluePin = 11 ;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(RedPin, OUTPUT);
pinMode(BluePin, OUTPUT);
pinMode(GreenPin, OUTPUT);
}
void loop() {
if(irrecv.decode(&results))
{
long int decCode = results.value;
MICROPROCESSOR

Serial.println(decCode,HEX);
switch(decCode){
case 16724175:
{
Serial.println("RED");
setColor(255, 0, 0);
}
break;
case 16718055:
{
Serial.println("GREEN");
setColor(0, 255, 0);
}
break;
case 16743045:
{
Serial.println("BLUE");
setColor(0, 0, 255);
}
break;
case 16716015:
{
Serial.println("YELLOW");
setColor(255, 255, 0);
}
break;
case 16726215:
MICROPROCESSOR

{
Serial.println("PURPLE");
setColor(255, 0, 255);
}
break;
case 16734885:
{
Serial.println("AQUA");
setColor(0, 255, 255);
}
break;
case 16728765:
{
Serial.println("WHITE");
setColor(255, 255, 255);
}
break;
case 16730805:
{
Serial.println("OFF");
setColor(0, 0, 0);
}
break;
default:
Serial.print("");
}
irrecv.resume();
MICROPROCESSOR

}
}
void setColor(int red, int green, int blue)
{
analogWrite(RedPin, red);
analogWrite(GreenPin, green);
analogWrite(BluePin, blue);
}
MICROPROCESSOR

You might also like