Improved Arduino TV-B-Gone

I have a new, improved version of the Arduino TV-B-Gone software available. This version fixes the European codes, among other things. (Download here).

The TV-B-Gone is a tiny infrared remote that can turn off almost any TV. A while ago, I ported the TV-B-Gone software to the Arduino; for details on the port and how it works see my previous post on the Arduino TV-B-Gone.

Mitch Altman, the inventor of the TV-B-Gone, made some improvements to the code for a weekly TV-B-Gone constructing workshop in San Francisco at Noisebridge. If you're in the San Francisco area and are interested in the TV-B-Gone, you might want to check it out.

The main bug fix in the new version is the European codes will now work (if you ground pin 5). (The problem was a bunch of #ifdefs to fit the codes into the ATtiny's limited memory; taking out the #ifdefs fixed the problems.) Pressing the trigger button during transmission will now restart the codes. The delay between codes was increased, which should make transmission more reliable. The Arduino's processor will now sleep when not transmitting (thanks to ka1kjz). (Unfortunately, the rest of the Arduino components are still draining power, so sleep mode will be more useful with stripped-down Arduino variants.)

Important: the pins have been changed around in the new version (to avoid conflicts with the serial port). Pin 2 is now the trigger switch, Pin 3 is the IR output, and Pin 5 is grounded if you want European codes. If you built an Arduino TV-B-Gone before and want to use the new code, make sure you connect to the right pins.

Here's Mitch Altman's schematic for the Arduino TV-B-Gone (click for larger): Arduino TV-B-Gone schematic

To build the Arduino TV-B-Gone, follow the above schematic and download the sketch. My previous post on the Arduino TV-B-Gone has more information on wiring it up, if you need it.

I've also created a github repository for this code.

32 comments:

sewa mobil said...

Nice article, thanks for the information.

William said...

I've tried several different IrLED's but they all do the same.
They do a fade blink every now and then while it's spamming the codes.

Any idea why? I have the Arduino Mega.

Anonymous said...

Thx for the nice conversion and upgrade. Version 1.2 runs fine on my arduino nano.

(TV-B-Gone for Arduino version 0.001
Ported to Arduino by Ken Shirriff, Dec 3, 2009
http://arcfn.com
The original code is:
TV-B-Gone Firmware version 1.2)

But :
I have to set digital pin 5 floating to to turn my european phi**ips tv on and off (place germany/eu ;-); the tv was bought in germany). If i ground digital pin 5 my tv just switches channels several times during a single run.
I tried this with a fet and a MOSFET (IRLU 2905) as driver for my IR LED ->no changes.
Hardware for IRLU 2905:
Source connected to GND,
Gate connected to arduino out (digital pin 3) with 10 KOhm to ground to get a proper not floating MOSFET gate and
Drain connected to IR-LED with 39 Ohm in series to VCC/+5Volt).
This works for a distance of several meters and really large IR LEDs or several ;-).
With a floating digital pin 5 everything works like it should. It toggles tv off or on with every single run, no channel switching. Just one single action per run.

turbo_b. 28th of dec.2010

Anonymous said...

Thanks Ken

Arduino TV B-Gone v 1.2 is running fine.

I noticed that the "region blink", that the LED runs at first power up, is delayed by 3 seconds.

I will report back the current draw on the ATmega in a few days.

cheers!

Anonymous said...

How hard would this be to adapt to use Ladyada's setup with two narrow beams and two wide beams?

Anonymous said...

Do I have to use three AA batteries or can i just use a 9v? Thanks!

Ken Shirriff said...

Anonymous1: the Arduino can take up to 12 volts input voltage: http://www.arduino.cc/en/Main/ArduinoBoardDiecimila

Anonymous2: you can easily add 4 LEDs, but you'll need 5 transistors. See Ladyada's schematic for how to hook it up: http://www.ladyada.net/make/tvbgone/design.html

Anonymous said...

Thanks Ken!

hippi97 said...

don't work i got error:
TVB\WORLDcodes.cpp.o:(.progmem.data+0x0): multiple definition of `NApowerCodes'
WORLDcodes.cpp.o:(.progmem.data+0x0): first defined here
TVB\WORLDcodes.cpp.o:(.progmem.data+0x112): multiple definition of `EUpowerCodes'
WORLDcodes.cpp.o:(.progmem.data+0x112): first defined here
TVB\WORLDcodes.cpp.o:(.data.num_NAcodes+0x0): multiple definition of `num_NAcodes'
WORLDcodes.cpp.o:(.data.num_NAcodes+0x0): first defined here
TVB\WORLDcodes.cpp.o:(.data.num_EUcodes+0x0): multiple definition of `num_EUcodes'
WORLDcodes.cpp.o:(.data.num_EUcodes+0x0): first defined here


Please help this is so cool

BroHogan said...

@hippi97
I get those errors if I (mistakenly) unzip to sketchbook/libraries. Moved it to just sketchbook and the errors went away. Maybe your problem?

Stephen Tanner said...

Hey thank you for this port. I followed your design using a seeduino and it worked out better than expected. I get ~10m range at night. I built it into an old eyeglasses case and took it to the bars and had a lot of fun. Im using 4 AA's curently but a 9V doesnt seem to have enough (amps maybe?) to run the setup because the onboard led only flickers dimly and it doesnt seem to function. In order to make the whole thing smaller im probably going to use a smaller arduino and some AAA's.

nguyen said...

please execuse me b/c i'm a newbie. in your hand sketch, there's a value of "47" above the resistor connecting to pin 3 of arduino and another of "10" connecting to IR LED. are they 47 ohm and 10 ohm respectively ?

mutiemouse said...

Just a note for Mega users, use pin 9 instead of 3 for connecting of the LED driver circuit. Also change "#define IRLED 3" in "main.h" to 9.
Mega uses different timers for the pins. Ref: http://www.mythic-beasts.com/~markt/ATmega-timers.html

Anonymous said...

Hi,

I built the circuit (a bit differently than suggested) and it works as it should. :-)

I have some questions:
What currents Ib and Ic are occuring in the suggested circuit?

Isn't the value of the 47 Ohms resistor too low?

I just want to make sure that no critical currents are exceeded and the Arduino does not get damaged...

Or is everything o.k., because the IR Led is only pulsed?

Thanks!

Josef

goedenvraag said...

nice! and thanx. when saw this and directly made one! : http://youtu.be/KGvcM2i-P4o

Anonymous said...

No luck with mine programmed with a 5V/16Mhz Arduino Nano and Pin 5 is floating. I can replace the IR led with a green one and see it blink the codes but the TV never goes off. I'll try another IR led and use a 5 volt power supply.

Markus said...

Hi,
thanks! This is great!
But first, it didn't work with my Panasonic TV. The signal has to take about 2 seconds to turn off the TV, so I added a for-loop (3 times) for every POWER code. Now it works!

paul gaudre said...

nice job. Works fine.

Anonymous said...

no matter what i do my arduino uno and the sketchbook keeps getting errors with irremote sketches what do i do?

prometheus said...

This project is so cool, so I want to use this code. but, there are some problems
I got some errors.


TVB.cpp: In function 'void xmitCodeElement(uint16_t, uint16_t, uint8_t)':
TVB:91: error: 'TCCR2A' was not declared in this scope
TVB:91: error: 'COM2A0' was not declared in this scope
TVB:91: error: 'COM2B1' was not declared in this scope
TVB:92: error: 'TCCR2B' was not declared in this scope
TVB:92: error: 'WGM22' was not declared in this scope
TVB:105: error: 'TCCR2A' was not declared in this scope
TVB:106: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void setup()':
TVB:190: error: 'TCCR2A' was not declared in this scope
TVB:191: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void sendAllCodes()':
TVB:273: error: 'OCR2A' was not declared in this scope
TVB:274: error: 'OCR2B' was not declared in this scope


please help me. please

prometheus said...

So nice article

excuse me, but I have some errors.
please help me.


TVB.cpp: In function 'void xmitCodeElement(uint16_t, uint16_t, uint8_t)':
TVB:91: error: 'TCCR2A' was not declared in this scope
TVB:91: error: 'COM2A0' was not declared in this scope
TVB:91: error: 'COM2B1' was not declared in this scope
TVB:92: error: 'TCCR2B' was not declared in this scope
TVB:92: error: 'WGM22' was not declared in this scope
TVB:105: error: 'TCCR2A' was not declared in this scope
TVB:106: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void setup()':
TVB:190: error: 'TCCR2A' was not declared in this scope
TVB:191: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void sendAllCodes()':
TVB:273: error: 'OCR2A' was not declared in this scope
TVB:274: error: 'OCR2B' was not declared in this scope

prometheus said...

So nice article

excuse me, but I have some errors.
please help me.


TVB.cpp: In function 'void xmitCodeElement(uint16_t, uint16_t, uint8_t)':
TVB:91: error: 'TCCR2A' was not declared in this scope
TVB:91: error: 'COM2A0' was not declared in this scope
TVB:91: error: 'COM2B1' was not declared in this scope
TVB:92: error: 'TCCR2B' was not declared in this scope
TVB:92: error: 'WGM22' was not declared in this scope
TVB:105: error: 'TCCR2A' was not declared in this scope
TVB:106: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void setup()':
TVB:190: error: 'TCCR2A' was not declared in this scope
TVB:191: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void sendAllCodes()':
TVB:273: error: 'OCR2A' was not declared in this scope
TVB:274: error: 'OCR2B' was not declared in this scope

prometheus said...

So nice article

excuse me, but I have some errors.
please help me.


TVB.cpp: In function 'void xmitCodeElement(uint16_t, uint16_t, uint8_t)':
TVB:91: error: 'TCCR2A' was not declared in this scope
TVB:91: error: 'COM2A0' was not declared in this scope
TVB:91: error: 'COM2B1' was not declared in this scope
TVB:92: error: 'TCCR2B' was not declared in this scope
TVB:92: error: 'WGM22' was not declared in this scope
TVB:105: error: 'TCCR2A' was not declared in this scope
TVB:106: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void setup()':
TVB:190: error: 'TCCR2A' was not declared in this scope
TVB:191: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void sendAllCodes()':
TVB:273: error: 'OCR2A' was not declared in this scope
TVB:274: error: 'OCR2B' was not declared in this scope

prometheus said...

So nice article

excuse me, but I have some errors.
please help me.


TVB.cpp: In function 'void xmitCodeElement(uint16_t, uint16_t, uint8_t)':
TVB:91: error: 'TCCR2A' was not declared in this scope
TVB:91: error: 'COM2A0' was not declared in this scope
TVB:91: error: 'COM2B1' was not declared in this scope
TVB:92: error: 'TCCR2B' was not declared in this scope
TVB:92: error: 'WGM22' was not declared in this scope
TVB:105: error: 'TCCR2A' was not declared in this scope
TVB:106: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void setup()':
TVB:190: error: 'TCCR2A' was not declared in this scope
TVB:191: error: 'TCCR2B' was not declared in this scope
TVB.cpp: In function 'void sendAllCodes()':
TVB:273: error: 'OCR2A' was not declared in this scope
TVB:274: error: 'OCR2B' was not declared in this scope

Roy Cohen said...

hmm im curious. Would I be able to run this code properly on an arduino lillypad 8Mhz. I ask because I remember in the TV b gone the schematic referenced such an oscillator.

Roy Cohen said...
This comment has been removed by the author.
Roy Cohen said...
This comment has been removed by the author.
Hilary said...

I had the same errors as hippi97, and they went away when I moved the TVB folder out of libraries. Now I have a different error:
avrdude: stk500_getsync(): not in sync: resp=0x00

thanks for your advice,
Hilary
tech@a2zed.us

Augusto Masetti said...

I'm using an adafruit flora , but there isn't a pin 5 ,in it and this is the same code as provided by adafruit. ineed to change the region to EU for south america codes , the circuit looks and works but for the NA , how can i change it?

coffre-fort said...

I also tried several different IrLED's but they all do the same.

Gabriel said...

Ken, thanks for all your super hard work on this, and to Mitch Altman and Limor Fried (LadyAda) of course too! I finally got around to making my first ever TV B Gone, which is something I've wanted for over 6 months now! :) Here's a picture:

1) http://bit.ly/1diFnqp
2) http://bit.ly/1pXmoad

Thanks again!
Sincerely,
Gabriel
http://electricrcaircraftguy.blogspot.com/

Airless Spray said...

Nice idea you can improve more article!

melbourne web developer
melbourne web designer
Melbourne SEO Services
SEO Melbourne