Devices & Components
Arduino Uno Rev3
LED (generic)
Resistor 10k ohm
Infrared Receiver, Remote Control
Jumper wires (generic)
Project description
Code
This is the final code.
arduino
1#include <IRremote.h> 2 3int IRpin = 11; 4int ledpin = 6; 5int ledpin_2 = 5; 6int ledpin_3 = 4; 7IRrecv irrecv(IRpin); 8decode_results results; 9 10void setup() 11{ 12Serial.begin(9600); //open the serial port 13irrecv.enableIRIn(); // start receiving data 14pinMode(ledpin, OUTPUT); 15pinMode(ledpin_2, OUTPUT); 16pinMode(ledpin_3, OUTPUT);//define LED as output 17} 18 19void loop() 20{ 21if (irrecv.decode(&results)) { 22Serial.println(results.value, DEC); //print the value 23 24if(results.value==16754775) // your value here 25 { 26 digitalWrite(ledpin, HIGH); // turn the LED on 27 28 } 29if(results.value==16769055) // your value here 30 { 31 digitalWrite(ledpin, LOW); // turn the LED off 32 33 } 34if(results.value==16712445) // your value here 35 { 36 digitalWrite(ledpin_2, HIGH); // turn the LED on 37 38 } 39if(results.value==16720605) // your value here 40 { 41 digitalWrite(ledpin_2, LOW); // turn the LED off 42 43 } 44if(results.value==16736925) // your value here 45 { 46 digitalWrite(ledpin_3, HIGH); // turn the LED on 47 48 } 49if(results.value==16753245) // your value here 50 { 51 digitalWrite(ledpin_3, LOW); // turn the LED off 52 53 } 54 55 56irrecv.resume(); // receive the next value 57} 58}
Comments
Only logged in users can leave comments