loading

There are 3 remote's just to watch my television, for TV, set top box and sound bar. Procedure to watch TV is switching on TV putting its source to A/V, switching on sound system and putting its source to aux and switching on set top box. This is too confusing and frustrating to my parents and even to me some times. Just buying an universal remote just adds another remote to my remote arsenal.

So I want make a device that would reduce usage to single remote by automatically sending other remotes signals upon receiving one remote signal.

In my case I want to switch on my TV and sound system automatically and sets them to their correct sources by switching on set top box.

Step 1: Parts Needed

Parts needed to build this device

  1. Arduino
  2. IR receiver
  3. IR LED - emitter
  4. Some resistors
  5. Prefboard
  6. Some wires

Step 2: Planning

I decided to use Arduino mini pro for this device because of its small form factor.

I salvaged IR receiver form an old broken DVD player that was lying around. If possible take a note of pinout of receiver from its datasheet as it seems to be changing from device to device.

I have ordered IR LED’s on ebay and unfortunately they are high power narrow beam (22 degrees) LED’s which are commonly used for infrared light for security cameras but cannot be used for remote. So I decided to use them by grouping 4 of those together in series just to increase beam angle.

They are rated as 100mA forward current, so if I connect them in series total current draw would be around 400 mA.

And these are my requirements to achieve for this project.

source button --> function to be performed when source is pressed

settop box power --> tv power, tv a/v, soundbar power, soundbar aux

settop box volumeup1, set volumeup2 --> soundbar volumeup

settop box volumedown1, set volumedown2 --> soundbar volumedown

Step 3: Test Build

First we need to build a test set-up to have proof of concept and Arduino-IRremote library compatibility with the device.

Library can be downloaded at https://github.com/z3t0/Arduino-IRremote

IR receiver can be directly connected to Arduino

  • VCC of IR receiver to 5v
  • Ground to Ground
  • And signal pin of IR receiver to any digital pin of Arduino. (Change that in code respectively)

Note: Be sure the pin out of IR receiver before connecting, they can be easily damaged with wrong wiring.

I also connected IR led to digital pin 3 which is PWM pin. (This depends on type of Arduino you are using, details in last step)

If you don’t know which resistor to be used with leds use this calculator to know the value.http://www.hobby-hour.com/electronics/ledcalc.php

Now the test set-up in place, we can read some remote codes to use in our Arduino code, read codes of all buttons we are using in this project.

I found nice article about Arduino-IRremote library at https://www.pjrc.com/teensy/td_libs_IRremote.html which explains a lot about this library. I developed my code based on ‘example program for receiving’ in that article.

A simple if condition can be written to translate what to do when master remote command is received. Infrared codes can be sent from the same set-up by using IRsend object.

Always keep any camera around when testing this as infrared light can only be seen with IR sensitive cameras

This is second time I am building the same project, in previous one I did not use the library, I literally measured micro seconds gap between the Infrared pulses from remote and made those delay numbers as a byte array and blinked IR led with those gaps in between. Major problem with that kind of set-up is memory, Arduino mini pro has very little memory and those byte arrays are huge. And that set-up is also not reliable as using library.

Step 4: Building

So after testing the code it is time to move whole test set-up to permanent board. I have used FQP50N06 N-channel MOSFET to amplify the PWM signal from Arduino pin 3.

I used female header to mount Arduino to the perfboard so that I can remove the Arduino if anything goes bad in future.

I don’t trust sensor because this is second time I am building this project, so I am re using same sensor for 3 times. So I am using female headers to mount the sensor, so that it can be replaced any time. It can also be helpful to extend the sensor in case I need any adjustments.

Digital pins of Arduino can only handle 40mA and I don’t have any transistor that can handle 500 mA current draw for group of LED’s, so I decided to use an N-channel MOSFET to amplify the PWM signal from Arduino pin 3.

If the LED’s are below 40mA they can be directly connected to digital pin of Arduino by adding 220ohms resistor.

I designed the layout in fritzing and followed the schematics to solder on to a perfboard.

For portability purpose I am planning to use 9v battery to power the device by connecting to raw pin of Arduino but I am concerned that those high power LED's can drain battery quickly. So first I will use this device with battery and mark the battery life if it is reasonable I will continue to use on battery otherwise I will switch to a wall adapter of around 9 volts. So I also have added two male jumper pins to board to connect positive and negative wires form power supply.

I also added a red led with 220ohm resistor to indicate the activity of arduino, next key press can be accepted after led is off.

This project can be rebuilt for any setup by simply modifying codes and if condition in the Arduino code.

Now I should find good enclosure to fit everything nicely.

#include <IRremote.h>

const int RECV_PIN = 12;
const int ACT_PIN = 11;
int repeat = 3; 

unsigned long currcode;
unsigned long prevcode;

//settop box codes
const unsigned long stpower = 0x11D9D02F;
const unsigned long volumeup1 = 0x11D948B7;
const unsigned long volumedown1 = 0x11D958A7;
const unsigned long volumeup2 = 0x11D98E71;
const unsigned long volumedown2 = 0x11D94EB1;

//tv codes
unsigned long tpower = 0x1CE338C7;
unsigned long av = 0x1CE328D7;

//soundbar codes
unsigned long sbpower = 0x1100C;
unsigned long aux = 0x11038;
unsigned long volumeup = 0x11010;
unsigned long volumedown = 0x11011;

IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode(ACT_PIN, OUTPUT);
  irrecv.blink13(true);
}void loop() {
  if (irrecv.decode(&results)) {
    if (results.decode_type != UNKNOWN )
    {
      if (results.value != REPEAT )
      {
        currcode = results.value;
      }
      else if (results.value == REPEAT )
      {
        if (prevcode == volumeup1 || prevcode == volumeup2 || prevcode == volumedown1 || prevcode == volumedown2)
        {
          currcode = prevcode;
        }
        else
        {
          currcode = 0;
        }
      }
      if (currcode == stpower)
      {
        digitalWrite(ACT_PIN, HIGH);
        Serial.println("power");
        irsend.sendNEC(tpower, 32);
        delay(500);
        irsend.sendRC6(sbpower, 20);
        delay(1500);
        irsend.sendNEC(av, 32);
        delay(500);
        digitalWrite(ACT_PIN, LOW);
      }
      else if (currcode == volumeup1 || currcode == volumeup2)
      {
        for (int i = 0; i < repeat; i++)
        {
          digitalWrite(ACT_PIN, HIGH);
          Serial.println("volumeup1");
          irsend.sendRC6(volumeup, 20);
          delay(500);
          digitalWrite(ACT_PIN, LOW);
        }
      }
      else if (currcode == volumedown1 || currcode == volumedown2)
      {
        for (int i = 0; i < repeat; i++)
        {
          digitalWrite(ACT_PIN, HIGH);
          Serial.println("volumedown1");
          irsend.sendRC6(volumedown, 20);
          delay(500);
          digitalWrite(ACT_PIN, LOW);
        }
      }
      else
      {
        //do nothing
      }
    }
    prevcode = currcode;
    irrecv.resume();
    irrecv.enableIRIn(); //trust me this has to be done again
  }
}

Step 5: Transmitting Pin

Transmit pin for this library is dependent on the Arduino model we are using, for example if we are using Arduino mega the transmit pin is digital pin 9, if we are using mini pro or uno transmit pin is digital pin 3. That transmit pin is based on timer of the AVR chip we are using which is different for different chips.

For more details open IRremoteInt.h file in libraries\Arduino-IRremote-master folder

There we can find some code which determines which timer to use when using different boards for the library.

If you really want, you can modify this code to change PWM pin for transmitting.

// Define which timer to use
//
// Uncomment the timer you wish to use on your board.
// If you are using another library which uses timer2, you have options to
//   switch IRremote to use a different timer.
// Arduino Mega

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
	//#define IR_USE_TIMER1   // tx = pin 11
	#define IR_USE_TIMER2     // tx = pin 9
	//#define IR_USE_TIMER3   // tx = pin 5
	//#define IR_USE_TIMER4   // tx = pin 6
	//#define IR_USE_TIMER5   // tx = pin 46

// Teensy 1.0
#elif defined(__AVR_AT90USB162__)
	#define IR_USE_TIMER1     // tx = pin 17

// Teensy 2.0
#elif defined(__AVR_ATmega32U4__)
	//#define IR_USE_TIMER1   // tx = pin 14
	//#define IR_USE_TIMER3   // tx = pin 9
	#define IR_USE_TIMER4_HS  // tx = pin 10

// Teensy 3.0 / Teensy 3.1
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
	#define IR_USE_TIMER_CMT  // tx = pin 5

// Teensy-LC
#elif defined(__MKL26Z64__)
  #define IR_USE_TIMER_TPM1 // tx = pin 16

// Teensy++ 1.0 & 2.0
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
	//#define IR_USE_TIMER1   // tx = pin 25
	#define IR_USE_TIMER2     // tx = pin 1
	//#define IR_USE_TIMER3   // tx = pin 16

// Sanguino
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
	//#define IR_USE_TIMER1   // tx = pin 13
	#define IR_USE_TIMER2     // tx = pin 14

// Atmega8
#elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__)
	#define IR_USE_TIMER1     // tx = pin 9

// ATtiny84
#elif defined(__AVR_ATtiny84__)
  #define IR_USE_TIMER1     // tx = pin 6

//ATtiny85
#elif defined(__AVR_ATtiny85__)
  #define IR_USE_TIMER_TINY0   // tx = pin 1

// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
#else
	//#define IR_USE_TIMER1   // tx = pin 9
	#define IR_USE_TIMER2     // tx = pin 3

#endif
<p>when i get it done with the attiny85 i will post some pics here, thanks again</p>
<p>I would love to see your work, thanks :)</p>
and she I try touplod the sketch it says 'Serial' was not declared in this scope, and I Don't know what pins to used for the it receiver and it send, maybe you can help me fixing my code please, if I get it work I will post it with the PCB pics and all, to honor you. thanks again
#include <br><br>const int RECV_PIN = 12;<br>const int ACT_PIN = 11;<br>int repeat = 1;<br><br>unsigned long currcode;<br>unsigned long prevcode;<br><br>//settop box codes PIONER<br>const unsigned long Bpower = 0xFD00FF;<br>const unsigned long Bchleft = 0xFD20DF; &nbsp; ///PIONER<br>const unsigned long Bchright = 0xFD609F;<br>const unsigned long Bvolup = 0xFD807F;<br>const unsigned long Bvoldw = 0xFD906F;<br>const unsigned long Bmute1 = 0xFDB04F;<br>const unsigned long Binfo = 0xFD708F;<br>const unsigned long Bguia = 0xFD40BF;<br>const unsigned long Bsalir = 0xFD30CF;<br>const unsigned long Batras = 0xFD18E7;<br>const unsigned long Badelante = 0xFD58A7;<br>const unsigned long Bplay = 0xFD9867;<br>const unsigned long Bstop1 = 0xFDA857;<br>const unsigned long Brec = 0xFD6897;<br>const unsigned long Bprevch = 0xFD48B7;<br>const unsigned long Bok = 0xFDA05F;<br>const unsigned long Bch106 = 0xFD08F7;<br>const unsigned long Bch1602 = 0xFD8877;<br><br><br>//tv and cable codes<br>unsigned long Apower = 0xE17A48B7;<br>unsigned long Achleft = 0xE17A30CF; &nbsp; ///PIONER<br>unsigned long Achright = 0xE17AD02F;<br>unsigned long Avolup = 0xE17A38C7;<br>unsigned long Avoldw = 0xE17AD827;<br>unsigned long Amute1 = 0xE0E0F00F;<br>unsigned long Ainfo = 0xE17AC837;<br>unsigned long Aguia = 0xE17A12ED;<br>unsigned long Asalir = 0xE17A50AF;<br>unsigned long Aatras = 0xE17A2CD3;<br>unsigned long Aadelante = 0xE17AAC53;<br>unsigned long Aplay = 0xE17A6C93;<br>unsigned long Astop1 = 0xE17A4CB3;<br>unsigned long Arec = 0xE17ACC33;<br>unsigned long Aok = 0xFE17AA857;<br>unsigned long Aprevch = 0xE17A8877;<br>unsigned long Ach106 = 0xFD08F7;<br>unsigned long Ach1602 = 0xFD8877;<br>unsigned long Ach1 = 0xE17A807F;<br>unsigned long Ach0 = 0xE17A00FF;<br>unsigned long Ach6 = 0xE17A609F;<br>unsigned long Ach2 = 0xE17A40BF;<br><br><br><br>IRrecv irrecv(RECV_PIN);<br>IRsend irsend;<br>decode_results results;<br><br>void setup()<br>{<br>&nbsp; Serial.begin(9600);<br>&nbsp; irrecv.enableIRIn();<br>&nbsp; pinMode(ACT_PIN, OUTPUT);<br>&nbsp; irrecv.blink13(true);<br>}<br>void loop() {<br>&nbsp; if (irrecv.decode(&amp;results)) {<br>&nbsp; &nbsp; if (results.decode_type != UNKNOWN )<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; if (results.value != REPEAT )<br>&nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; currcode = results.value;<br>&nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; else if (results.value == REPEAT )<br><br>&nbsp; &nbsp; &nbsp; &nbsp; if (currcode == Bchleft)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;CHLEFT&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Achleft, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bpower)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;POWER&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Apower, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bchright)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;CHRIGHT&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Achright, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bvolup)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;volumeUP&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Avolup, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bvoldw)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;volumeDown&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Avoldw, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bmute1)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Mute&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Amute1, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Binfo)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Info&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ainfo, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bguia)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Guide&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aguia, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bsalir)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Exit&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Asalir, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Batras)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Bwd&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aatras, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Badelante)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Fwd&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aadelante, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bplay)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Play / Pause&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aplay, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bstop1)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Stop&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Astop1, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Brec)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;Rec&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Arec, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bok)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;ok&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aok, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bprevch)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, HIGH);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;PrevCh&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aprevch, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(200);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bch106)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;CH106&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ach1, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ach0, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ach6, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aok, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; /////////////////////////////////////<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (currcode == Bch1602)<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; repeat; i++)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.println(&quot;CH1602&quot;);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ach1, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ach6, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ach0, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Ach2, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; irsend.sendNEC(Aok, 32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay(100);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digitalWrite(ACT_PIN, LOW);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //do nothing<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; prevcode = currcode;<br>&nbsp; &nbsp; irrecv.resume();<br>&nbsp; &nbsp; irrecv.enableIRIn(); //trust me this has to be done again<br>&nbsp; }<br>}<br><br><br><br>and i got the error after i compile.<br>i dont know hot to fix it&nbsp;<br>i want to do it with attiny85<br>it works perfect with the arduino nano<br>but i dont know wich pin to use for the ir receiver and the ir sender. if you can help me please.&nbsp;<br>thanks soo much is was image so far it like I say I want to do it with a attiny85 just can't he it work, here's my code,<br>
<p>Wow! it looks like a neat and useful project. While I don't understand most of the conversation at ground (pun) level - at the10,000 foot view, it looks good. Are there other products on the market that accomplish this? After a little &quot;making pretty&quot; can you say kickstarter? I will file this project for future. Now I just need to get that darn LED to blink! :):) Tim.</p>
<p>thank you, this project is as simple as blinking an led (with transistor), all the magic is in the coding which was handled by library. You can do this as your second project after blinking single led ;). Ask me if you need any help building this :)</p>
<p>i just love it, it help me a lot to understand more about programing, i new on arduino so it really helps me.</p><p>now i will like to do it with a attiny 85 but i dont know how to program the ir led and the receiver. i made a few changes on the scketch so it can work with my remote and it work perfect with my nano.</p><p>if you can please give me a little help to do it with the attiny85 i will apreciate it a lot</p><p>thanks so much for the instructable its awesome.</p>
<p>Thanks, their is a good instructable for making library compatible with attiny <a href="https://www.instructables.com/id/Attiny-IR-library/ " rel="nofollow">https://www.instructables.com/id/Attiny-IR-library/ </a> other than code changes everything should be same </p><p>Hope this helps.</p>
<p>i just love it, it help me a lot to understand more about programing, i new on arduino so it really helps me.</p><p>now i will like to do it with a attiny 85 but i dont know how to program the ir led and the receiver. i made a few changes on the scketch so it can work with my remote and it work perfect with my nano.</p><p>if you can please give me a little help to do it with the attiny85 i will apreciate it a lot</p><p>thanks so much for the instructable its awesome.</p>
<p>Really nice project, it works super with a samsung ir/rf remote (Horizon Box) and my NAD amp. </p><p>My next wish is to combine this sketch with a repeater function for the &quot;not translated&quot; commands. Because my NAD amp has more functions and the original repeater I used had to be disconnected from the IR input. And the amp is behind closed doors. Tried to connect the both signals from the Arduino translator and simple repeater in parallel, but this was no succes.</p>
<p>Thank you, Repeating function can be added easily to this project. If your need is to add repeating function you can simply send same command you received by modifying existing if condition :)</p>
<p>Cool! I'll try to do it. If I manage to do it, I'll post here as a &quot;I Made it!&quot; response</p>
<p>grate, if you need any help please ask.</p>
<p>looks great. Just one correction. If you connect the LED' s in series, the current remains 100mA.<br>Only if you put them parallel, will the current increase be possible.<br>Putting LED' s dirctly paarllel is usually not a good idea, but is OK if each has their own series resistor</p>
Thanks for correcting, got little confused there :) first i thought of connecting them parallel to each other but i did it in series just for simplicity
<p>:-) We all get confused from time to time. I have made sillier mistakes</p>
<p>Nice</p>
<p>thank you</p>
<p>thank you</p>
<p>it's cool</p>
<p>thank you</p>

About This Instructable

5,462views

105favorites

License:

More by vamsikurre:Simple LED strip party lights using arduino Arduino Android USB serial communication with OTG cable Repair and upgrade dodgy mouse 
Add instructable to: