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):
To build the Arduino TV-B-Gone, follow the above schematic and download the sketch from github. My previous post on the Arduino TV-B-Gone has more information on wiring it up, if you need it.
Nice article, thanks for the information.
ReplyDeleteI've tried several different IrLED's but they all do the same.
ReplyDeleteThey do a fade blink every now and then while it's spamming the codes.
Any idea why? I have the Arduino Mega.
Thx for the nice conversion and upgrade. Version 1.2 runs fine on my arduino nano.
ReplyDelete(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
Thanks Ken
ReplyDeleteArduino 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!
How hard would this be to adapt to use Ladyada's setup with two narrow beams and two wide beams?
ReplyDeleteDo I have to use three AA batteries or can i just use a 9v? Thanks!
ReplyDeleteAnonymous1: the Arduino can take up to 12 volts input voltage: http://www.arduino.cc/en/Main/ArduinoBoardDiecimila
ReplyDeleteAnonymous2: 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
Thanks Ken!
ReplyDeletedon't work i got error:
ReplyDeleteTVB\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
@hippi97
ReplyDeleteI get those errors if I (mistakenly) unzip to sketchbook/libraries. Moved it to just sketchbook and the errors went away. Maybe your problem?
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.
ReplyDeleteplease 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 ?
ReplyDeleteJust 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.
ReplyDeleteMega uses different timers for the pins. Ref: http://www.mythic-beasts.com/~markt/ATmega-timers.html
Hi,
ReplyDeleteI 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
nice! and thanx. when saw this and directly made one! : http://youtu.be/KGvcM2i-P4o
ReplyDeleteNo 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.
ReplyDeleteHi,
ReplyDeletethanks! 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!
nice job. Works fine.
ReplyDeleteno matter what i do my arduino uno and the sketchbook keeps getting errors with irremote sketches what do i do?
ReplyDeleteThis project is so cool, so I want to use this code. but, there are some problems
ReplyDeleteI 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
So nice article
ReplyDeleteexcuse 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
So nice article
ReplyDeleteexcuse 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
So nice article
ReplyDeleteexcuse 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
So nice article
ReplyDeleteexcuse 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
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.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI 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:
ReplyDeleteavrdude: stk500_getsync(): not in sync: resp=0x00
thanks for your advice,
Hilary
[email protected]
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?
ReplyDeleteI also tried several different IrLED's but they all do the same.
ReplyDeleteKen, 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:
ReplyDelete1) http://bit.ly/1diFnqp
2) http://bit.ly/1pXmoad
Thanks again!
Sincerely,
Gabriel
http://electricrcaircraftguy.blogspot.com/
The resistors are of 10K and 47K or 10ohms and 47ohms??
ReplyDeletethanks!
Could someone do the same but to work on Atmega8A? Is it possible? I've got lots of these. PLEASE
ReplyDeletei have tested the code and i have some problems :
ReplyDeleteTVB\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
Tested with arduino 1.0.5 for an atmega 168.
I try my chance here with not much hope :D
ReplyDeleteI want to run this on a 12Mhz clock.
I tried changing DELAY_CTN to 11 but it doesn't seem to work.
Would you have any advice on how to i could make it work for such a device (a Pro Trinket 3V/12Mhz from adafruit).
Thanks for sharing that work :) !!
This comment has been removed by the author.
ReplyDelete(referring to these 2 pictures):
ReplyDeleteMy 1st TVBGone, pic1
My 1st TVBGone, pic2
Alex,
if that comment was for me, about the resistors, here's my answer: I can't vouch for that picture with 100% certainty anymore because I made that device a long time ago and have since permanently moved it to a PCB somewhere, but I have since then built another 6 or 8 or so TVBGones (as gifts) and I am most often using the following:
Transistor: 2N3904
R_base = 510 Ohms
R_collector = 10 Ohms
The Arduino I'm using in the picture is a cheapo 5V Pro Mini, and I'm running the regulated 5V to the transistor Collector (though you could probably pull more power and get better IR range if you resized the resistors and ran power straight from the 9V battery to the Collector instead).
My range is ~15 ft. Maybe a touch more if you have good aim.
Sincerely,
Gabriel Staples
http://electricrcaircraftguy.blogspot.com/
I am getting a compiling error:
ReplyDeleteTVB/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
What's up?
Ken, I want to let you know I have put your code on Github, here: https://github.com/ElectricRCAircraftGuy/TVBGone. This will hopefully make it easier for people to add to it if they wish, or edit it to port to other devices if they wish. I have made only very minor changes to it. I may have changed some pins or something (it was a long time ago I worked on it), and I added debouncing to the button (prob. not necessary, but I did it anyway to be thorough). Anyway, just wanted to let you know. For complete info people can read the readme at my link above.
ReplyDelete~Gabriel Staples
http://electricrcaircraftguy.blogspot.com/
FYI Everyone, this code will NOT compile in Arduino 1.5.7 or later, due to the newer Arduino IDEs using a newer version of the gcc compiler, which has changed the way progmem is handled. I am using Arduino 1.5.6-r2 Beta to compile and upload this code to my Arduino.
ReplyDelete~Gabriel Staples
Thanks gabe, please update your code Ken i really wanna make this dope device
ReplyDeleteI keep getting an error saying StructIrCode is already defined or something, even when using the older software. (1.5.2 rev 2 beta). Please help me out with this i need to get this in for science fair asap.
ReplyDeleteKen, sorry for posting a slightly modified version of your code on GitHub without properly forking it. Somehow I overlooked your GitHub link at the bottom of your article above, or I would have forked from there. In either case, when I get the chance I'll help update to update your root version of the code to make it compatible with the current Arduino IDE, so that will be something I get to sometime.
ReplyDeleteGabriel, I will be checking this website frequently. Please let me know when you fix the code and how i can access it. Thanks,
ReplyDeleteEvan
Hi ken, im doing the tv b gone and when i compile the project i get this error comment, if u can hlep me, i would be very pleased. Thanks for your time
ReplyDeleteIn file included from main.h:1:0,
from TVB.ino:33:
TVB:78: error: variable 'NApowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
TVB:79: error: variable 'EUpowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
variable 'NApowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Any fix for:
ReplyDelete"undefined reference to 'NApowerCodes'"
... and ...
"undefined reference to 'EUpowerCodes'"
after const has been added?
i have got these error codes:
ReplyDeleteIn file included from main.h:1:0,
from TVB.pde:33:
TVB.pde:78:30: error: variable 'NApowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
TVB.pde:79:30: error: variable 'EUpowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Error compiling.
can someone help me please?
IF YOU GET NAPOWERCODES OR EUPOWERCODES MUST BE CONST,DOWNGRADE YOUR ARDUINO IDE. TEST IT. IT WORKS.
ReplyDeleteHere is a link to the TV-B-Gone sketch which has been corrected and WILL COMPILE/RUN on an Arduino Uno @ 16Mhz, AND BUILDS IN THE NEW ARDUINO SOFTWARE. If you have been an able to build the sketch and run it on your Arduino UNO, TRY THIS -- IT WORKS!
ReplyDeleteDOWNLOAD HERE:
http://cornfieldelectronics.com/cfe/projects/tvbg_arduino/arduino_sketches/TVBGone_Sketch.zip
The above URL, to that sketch, can be found here:
http://cornfieldelectronics.com/cfe/projects/tvbg_arduino/tvbg_arduino_workshop.php
Just look, on the page, for, "3) You also need the TV-B-Gone Arduino Sketch"
I also have the problem of that when I try to compile it broadcasts these errors:
ReplyDeleteTVB/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
And can't figure out how to fix them with my limited knowledge of coding, any ideas?
Please help its a cool project but I cant get it to Work.
Ok, so now I fixed those errors with a version after 1.5.7, but Im getting diffrent errors like:
ReplyDeleteIn file included from main.h:1:0,
from TVB.ino:33:
TVB.ino:78:30: error: variable 'NApowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
TVB.ino:79:30: error: variable 'EUpowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Error compiling.
Please help.
Hi all. for those who encountered errors:
ReplyDeletei had the same problem with all of you, every few lines some error occurs, after a few hours of playing with the code and the libraries and reading the Ken's method (http://www.righto.com/) of coding for hundreds of times, i found that the problem is not the code itself, I've tried fixing every error, changing every port and finally came to this:
version 1.0.3 (http://arduino.googlecode.com/files/arduino-1.0.3-windows.zip) of arduino IDE for windows, just uploaded it to my UNO R3 without any errors and it works great. i have used no transistors or resistors, just pinned anode of the IR LED to pin 3 and then grounded the LED cathode to GND right next to pin 13. turns every single TV that i have tested so far off, 30 years olds from sony to toshiba and high end samsung TVs.
I try your version Amir but i have the same problem :/
ReplyDeleteKen, please post a link at the top of this article to the latest version of your code, just updated, here.
ReplyDeleteEvan, Marti, Brett, Michel, Joseph, Amir, Mistifyer, and anyone else who couldn't get the code to compile, please see my link just above. I just updated the code on GitHub. Let me know via the GitHub Issues page if you have any problems.
ReplyDelete~Gabriel, www.ElectricRCAircraftGuy.com
I tried this project a few months ago but came across many of the same errors as the people above.
ReplyDeleteThis new code works excellently and without any problems.
Although I did have a question, inside the new code you give instructions on how to build it:
The hardware for this project uses an Arduino:
Connect an IR LED to pin 3 (IRLED).
Connect a visible LED to the pin 13 (or use the built-in LED in many Arduinos).
Connect a push-button between pin 2 (TRIGGER) and ground.
Pin 5 (REGIONSWITCH) must be left floating for North America, or wire it to ground to have it output European codes.
I was interested in whether there is still benefit to using a transistor and resistor attached to the IR led?
What is your experience?
Can I use only microcontroller only of Arduino Uno?
ReplyDeleteHello
ReplyDeleteI made your modified project, and it works.
I am in Europe, and the Europe link is in place. Until now, I only try it on my own TV, but sadly it doesn't work on it.
I adjusted the resistor quite low to get a strong power on the IR's leds. They looks to work well (looking with a camera on it)
Will try again on other TV's
The goal going this hack was to be able to shut off TV in front of us, because my 2 years old girl never see TV's and I don't want her to see until older. By the way now our gov. recognize Child under 3 should never see TV, but it's not yet illegal to let them see.
Bring some addition and affect at lot child's brain enhancement.
Thanks a lot for your work. Previous versions were not possible anymore to use on arduinos !
Great! Thank you! Worked perfectly on a SONY TV.
ReplyDeleteAlso, thanks for, #mutiemouse note:
"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." (before that change it did not work on the Arduino Mega Board I have)
Where is the code?
ReplyDeleteHello, the code from github doesn't compile with newer Arduino IDE, when compiling for ATtiny85. a) the "undeclared in this scope" as mentioned above appears on ATtiny85, not on Arduino nano. But you can just add the definitions. Seems to work for me.
ReplyDeleteb) I had to remove many codes from WORLD_IR_CODES.h cause the code got too big for the ATtiny85. Maybe the newer IDE avr-gcc isn't really efficient?