Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Project 14 IR-remote buttons reading

PROGRAM #1
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
Serial.println("Enabling IRin");
irrecv.enableIRIn(); // Start the receiver
Serial.println("Enabled IRin");
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
delay(100);
}
Project 15 IR-remote (Read pressed buttons and display)

PROGRAM #2
#include <IRremote.h> else if (results.value == BUTON2)
int RECV_PIN = 11; Serial.println("BUTON2");
IRrecv irrecv(RECV_PIN); else if (results.value == BUTON3)
decode_results results; Serial.println("BUTON3");
#define BUTON1 0xFF30CF else if (results.value == BUTON4)
#define BUTON2 0xFF18E7 Serial.println("BUTON4");
#define BUTON3 0xFF7A85 }
#define BUTON4 0xFF10EF irrecv.resume();
void setup() }
{ delay(100);
Serial.begin(9600); }
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
if (results.value == BUTON1)
Serial.println("BUTON1");
Project 15 IR-remote (Read pressed buttons and display)

if (irrecv.decode(&results)) {
PROGRAM #3
if (results.value == BUTON1) {
#include <IRremote.h> if(itsONled[1] == 1) {
int RECV_PIN = 11; digitalWrite(led1, LOW);
int led1 = 4; itsONled[1] = 0;
int led2 = 5; }
int led3 = 6; else {
int led4 = 7; digitalWrite(led1, HIGH);
int itsONled[] = {0,0,0,0,0}; itsONled[1] = 1;
IRrecv irrecv(RECV_PIN); }
decode_results results; Serial.println("BUTON1");
#define BUTON1 0xFF30CF }
#define BUTON2 0xFF18E7 else if (results.value == BUTON2) {
#define BUTON3 0xFF7A85 if(itsONled[2] == 1) {
#define BUTON4 0xFF10EF digitalWrite(led2, LOW);
#define BUTON5 0xFF38C7 itsONled[2] = 0;
#define BUTON7 0xFF42BD }
#define BUTON6 0xFF5AA5 else {
#define BUTON8 0xFF4AB5 digitalWrite(led2, HIGH);
#define BUTON9 0xFF52AD itsONled[2] = 1;
void setup() }
{ Serial.println("BUTON2");
Serial.begin(9600); }
irrecv.enableIRIn(); // Start the receiver else if (results.value == BUTON3) {
pinMode(led1, OUTPUT); if(itsONled[3] == 1) {
pinMode(led2, OUTPUT); digitalWrite(led3, LOW);
pinMode(led3, OUTPUT); itsONled[3] = 0;
pinMode(led4, OUTPUT);}
}
void loop() {
else { }
digitalWrite(led3, HIGH); irrecv.resume(); // Receive the next value
itsONled[3] = 1; }
} delay(100);
Serial.println("BUTON3"); }
}
else if (results.value == BUTON4) {
if(itsONled[4] == 1) {
digitalWrite(led4, LOW);
itsONled[4] = 0;
}
else {
digitalWrite(led4, HIGH);
itsONled[4] = 1;
}
Serial.println("BUTON4");
}
else if (results.value == BUTON5) {
Serial.println("BUTON5");
}
else if (results.value == BUTON6) {
Serial.println("BUTON6");
}
else if (results.value == BUTON7) {
Serial.println("BUTON7");
}
else if (results.value == BUTON8) {
Serial.println("BUTON8");
}
else if (results.value == BUTON9) {
Serial.println("BUTON9");

You might also like