//This code comes from IRrecvDemo under examples from the IRremote library // ITEM TWELVE- IR Receiver #include <IRremote.h> // include IRremote.h library int RECV_PIN = 10; //define RECV_PIN (variable) to be 10 IRrecv irrecv(RECV_PIN); // Set RECV_PIN (pin11) as the IR receiver decode_results results; // define results (variable) to be where results of the IR receiver is located void setup(){ Serial.begin(9600); //Set the baud rate to be 9600 irrecv.enableIRIn(); //enable IR decoding } void loop() { // if the decoding data has been received; store that data into results if (irrecv.decode(&results)) { //Show the data in hexadecimals in the serial monitor Serial.println(results.value, HEX); irrecv.resume(); // wait to receive the next group of signals } }
#include <IRremote.h> int RECV_PIN = 10; int ledPin = 3; // LED – digital 3 boolean ledState = LOW; //ledstate for storage of LED’s state IRrecv irrecv(RECV_PIN); decode_results results; void setup(){ Serial.begin(9600); irrecv.enableIRIn(); pinMode(ledPin,OUTPUT); // set LED to be in the output mode } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); // Once the code for the power button has been received, turn the mode of LED from HIGH to LOW or the other way. if(results.value == 0xFD00FF){ ledState = !ledState; // reverse it digitalWrite(ledPin,ledState); //Change the state of LED } irrecv.resume(); } }