First decode the tv remote and get the hex code for each button..This code will do that…
#include int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value } }
Copy the codes for the button say for channel up is 80BFA15E…ok to send this code connect an IR Led to pin no 3..
Check whether the remote model is NEC or SONY and use this code to send the value
#include <IRremote.h> IRsend irsend; const int buttonPin = 2; // the number of the pushbutton pin //const int ledPin = 3; int buttonState = 0; // variable for reading the pushbutton status void setup() { // pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); Serial.begin(9600); } void loop() { buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: irsend.sendNEC(0x80BFA15E, 32); } }
Now when the button is pressed the channel will change..If the remote is sony then use irsend.sendSony…