Battery Saving TV-B-Gone With Region/range Selection Switches





Introduction: Battery Saving TV-B-Gone With Region/range Selection Switches

What is the TV-B-Gone?
TV-B-Gone is a small gadget that can turn on and off virtually any TV in the world developed and sold as a kit by Adafruit. They also provide the source code and compiled firmware under Creative Common Share Alike license.
I would like to thank original developers at Adafruit for this great work and sharing ideas before starting showing my modification.

First trial
At first, I downloaded the firmware v1.1 and flashed an ATtiny85-20 and made it with only one transistor and two wide angle IR LEDs with two supercaps as shown below. The switch is connected to the supercap + so it will beam only when you press the button.  It worked fine, but the problem was it drained the supercaps too quickly. The first reason is, of course, low capacity (compared to batteries) of the supercaps, but there are other reasons, too. I didn’t have a resonator at 8MHz, so I burned the oscillator selection fuse bit of the ATtiny85-20 as internal 8MHz. The internal oscillator has benefits of omitting an external component and programmable, but there are serious down side; its frequency can be unstable and varies depending on the temperature and power supply, AND it consumes more power at high frequency settings.

After this first trial, I added a 8MHz ceramic resonator and uploaded v1.2 firmware on an ATtiny85V-10 and found it can last double the time than ATtiny85V-20 using internal oscillator. One full cycle of pulsing all the codes takes a little less than a minute and with this latest testing configuration, more than 30 times of full cycle worked with 2 supercaps before the voltage dropped below 1.7V (two in series).

Need to save battery
I have thought about to turn off the device before the full cycle finished once it either turn on or off a TV. Adafruit's firmware database is designed as the codes for popular TV models emits first.  So in most cases, long before it emits all the codes, my target TV is turned on or off.  I thought about to add a power switch but that wasn’t very attractive to me.

Idea and solution!!
A couple days later, I suddenly got a good idea to utilize the Region Detection pin (pin6 of the ATtiny85v). Once the program detects the region from the level of pin 6 (float (internal pull-up): US, pull-down: EU), it is not used any more until all the codes pulsing is finished. So, in US mode for example, after it started pulsing and when you want to stop it, forcing the pin6 to ground will exit the do loop in software and the device will go sleep. I tested both US and EU mode with modified code and worked fine. This way, you can save battery.

Here in this introduction, I included a picture of the assembled TV-B-Gone JeonLab, but the circuit, which will be shown and explained step by step, is quite simple, so you may be able to assemble one on any prototype board or even on a bread board. 

Step 1: Circuit Modification

The original design of the TV-B-Gone by Adafruit uses the pin 6 of ATtiny85v as region detection.  With a 10k pull-down resistor connected to the pin 6, the device generates codes for European TV models. Otherwise, floating the pin 6, it works for North American models and most Asian models as well. 

There are three circuits showing in this step: North American (US) models only, European (EU) models only, and all-in-one model with region selection switch.

The PCB I made and showed in the Intro section is the all-in-one model.

As you can see in the circuit diagram, the NA (or US) model has no pull-down resistor on the pin 6.  When you successfully turn on or off a TV in the middle of code generation (the visible LED blinking), simply push the button S2 will pull the pin 6 to the ground and the firmware will stop the process and go to sleep mode which doesn't consume the battery.

However, in EU model, the pin 6 is grounded by the pull-down resistor, R3, 10k, always.  But pulling up the pin 6 by pressing the button S2 and connect to Vcc, the modified firmware will stop the process and sleep.

The UNI (all-in-one, NA+EU) model simply has both in one by adding a slide switch.

Step 2: Parts

Here is the parts list for the UNI model.

- ATtiny85V-10 with firmware: x1
- 8pin DIP socket: x1
- 8MHz ceramic resonator with built-in capacitors: x1
- Narrow beam IR LED (20 degrees, 940nm): x1
- Wide beam IR LED (34 degrees (or 40) , 940nm): x2
- Slide switch (DPDT): x2
- NPN transistor (2N3904): x3
- PNP transistor (PN2907, 800mA): x1
- 3mm LED (green or red): x1
- Resistor (1k): x2
- Resistor (10k): x1
- Tactile switch: x2
- Bread board or prototype board or you can buy the PCB from me

Step 3: Firmware Modification

First of all, download the original firmware, v1.2, from Adafruit from this link.

Open the main.c from any text editor like Notepad and find the end of the DO loop where the 250ms delay before the next code generation.

          // delay 250 milliseconds before transmitting next POWER code

Just before these lines, add these two lines (three lines including the comment starting with //).

         // exit do loop if REGIONSWITCH is pressed
         if ((region == US && !(PINB & _BV(REGIONSWITCH)))
         || (region == EU && (PINB & _BV(REGIONSWITCH)))) break;

Now it will look like this together.

         // exit do loop if REGIONSWITCH is pressed
         if ((region == US && !(PINB & _BV(REGIONSWITCH)))
         || (region == EU && (PINB & _BV(REGIONSWITCH)))) break;
          // delay 250 milliseconds before transmitting next POWER code

Save and quit the text editor.

Now compile and create the .hex file and upload it to an ATtiny85v chip using your favorite programmer.
There are many commercial programmers but I have used one using the Arduino-ISP.  If you are interested, please visit my blog and see this post and this.

UPDATE: For those who are not familiar with AVR programming:
1. Download WinAVR ( and install.
2. Browse into where the WinAVR is installed: Start-All programs-WinAVR-20100110 and run Progrmmers Notepad
3. Open the source code and edit
4. Open the MAKEFILE and edit it (follow instruction in the post from my blog:
5. Go to Tools menu and click [WinAVR] Make all to compile. If you have any problem with compiling, look closely this MAKEFILE.
6. Now I assume you already have any kind of programmer (not software but a physical device to put your Attiny85 chip and connect it to your computer such as the one I introduced ( or DASA or any other commercial product.
7. Insert an Attiny85 chip on the programmer and plug it to your computer.
8. From the Programmers Notepad, go to Tools and click on [WinAVR] Program to upload the hex file.

Step 4: Assembling a Kit

Step 5: Power Source

As same as Adafruit’s original TV-B-Gone kit, my modified TV-B-Gone_JeonLab accepts any DC power source within 3-5V. The micro-controller, ATtiny85V, runs within 1.8-5.5V, but the IR LEDs consumes more power than the micro-controller, you need to keep the source voltage at least 3V.

Adafruit includes 2 AA battery holder in their kit, but I will not include any battery holder or connector in my kit in order to give more flexibility of choice of power source.  As long as the voltage of the source is within 3-5.5V, any battery or supercap can be used.  For example, 2-3 AA or AAA alkaline batteries, 3-4 rechargeable batteries like NiCd or NiMH, Li-ion (or Li-PO) rechargeable batteries or 2 of 2.5V (0r 2.7V) supercap (at least 10F).

I like supercaps. Even though they can not hold much charge compared to batteries, they can be charged quickly (less than a minute) through USB or 5V wall adapter and small and light.  So I decided to attach two supercaps to my TV-B-Gone_JeonLab.

The actual size of my modified PCB is slightly smaller than Adafruit’s which fits nicely at the back of 2 AA battery holder. Anyway, I figured someone would be interested in having supercaps as a power source and here is how I did.

First thing I did was to attach a male header a guide (plastic piece on one side) for assuring correct polarity of connection.  But this one was too tall compared to the other components.  So I cut the plastic guide and pins a little bit.  Using a small piece of double sided tap with foam two supercaps (2.5V, 10F) were attached to the bottom of the PCB and soldered in series together. In order for ensuring the supercaps in place securely, a thin cable tie was used. I cut one of those USB cable found from my junk box and attached female connector to the red (+) and black (-) wires of the USB cable.

Step 6: Test

With one full charge (about one minute), I could turn one of my TVs on and off more than 40 times from about 6.5m (21 feet) away. Of course I used STOP button right after it turned on (or off) the TV. It does save power!



    • Epilog Challenge 9

      Epilog Challenge 9
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Science of Cooking

      Science of Cooking

    We have a be nice policy.
    Please be positive and constructive.




    Hai ,

    What other transistor can I use instead of the 2N2907 please

    Kind Regards

    Any PNP bipolar junction transistor (BJT) having over 600mA of collector current will work.

    Hi i downloaded firmware1.2 from your link but it has in main.c regionswitch is it neccessery to add that // exit do loop if REGIONSWITCH is pressed

    if ((region == US && !(PINB & _BV(REGIONSWITCH)))
    || (region == EU && (PINB & _BV(REGIONSWITCH)))) break;

    If you downloaded the firmware from Adafruit's website (which is the link in my post here), you need to add those lines in the main.c.

    Hi I also read from your tutorial that attiny 85-20 runs at internal 8mhz and 85-10 runs external.I have a 85-20 so can I configure it to run at external 8mhz crystal/resonator

    Both can be configured for either internal or external oscillator. You need to set proper fuse bits for the configuration. Try to search for attiny85 fuse bit setting. You may also want to look at the datasheet (LINK), page 163 for maximum frequency vs voltage.

    What pnp resistor used for? i see several tv b gone design that just connected directly to npn transisitor, and how if i wanna get a longer range without considering battery life? hook up some more LEDs? and how? thanks

    The pnp transistor is for triggering the transistors for the LEDs. I also tried with npn transistors and it works fine. I just followed the same circuitry from Adafruit. Regarding the longer range modification, you need to calculate total current the IR LEDs will consume and pick a proper transistor (or power FET). I have seen those high power modification from here on Instructables. Try to search for high power TV b gone. Good luck and enjoy building one.

    Hi thank you for a great instructable.I have managed to create the make file in avr notepad and i didnt get any errors, but i dont know what to do next to get the code into attiny 85.Please can you give me a step by step guide to do so i am using usbisp and this will be my first attempt at using this device to programme a chip.

    Sorry, I haven't used the usbisp. Did you mean USBTiny ISP? If so, I believe has an excellent tutorial. See