Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Using Adruino as Remote Control to turn TV on/off automatically  (Read 3118 times)

0 Members and 1 Guest are viewing this topic.

a_netanel

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 18
  • Last login:August 28, 2022, 11:40:07 am
  • I want to build my own arcade controls!
I'm about to finish a vertical cab, in which I used a cheap 40 inch LCD TV, mounted vertically.
One problem I had, was that the TV would not turn on and off with the PC it is connected to.
The PC uses DVI so I could not use any HDMI CEC functionality.

What I came up with eventually, is an Arduino based IR transmitter that will send the right "remote control" command to the TV when the Windows starts and shuts down, as if I pressed the "Power" button on the remote.

The steps are roughly as follows:
1. Buy an Arduino board (I used an UNO clone that I already had), an IR transmitter  and receiver. I actually used 2 Arduino boards for testing. Given the price, you may want to do the same, but you can get away with just one.
2. Install the Arduino IDE .
3. Install the IRremote library.
4. Connect the receiver pins to the board. The data pin from the receiver to PIN 11 on the board, and 5v and ground to the corresponding pins.
5. Upload the IRrecvDump code from the examples in the IRremote library, to your board.
6. Open Serial Monitor.
7. Point the TV remote to the receiver and press the "Power" button. The monitor should print the data the it received. In my case it was "NEC, 4FB4AB5, 32 bits"
8. Use the above information to edit this script. Change the line:
Code: [Select]
irsend.sendNEC(0x4FB4AB5, 32);You can find the function name (sendNEC, for NEC...) in this file under the IRsend class.
9. Remove the receiver and connect the IR LED (Transmitter) to the Arduino. Use PIN3 for the data, and 5v and ground to the corresponding pins.
10. Upload the edited script to the board.

Now the board is configured to send the IR code every time it gets anything on the serial input. The next thing to do is to connect the board to the PC via USB and send anything (I simply send the letter "A") on the correct serial (COM) port.
I did it with a simple powershell script.

11. Install the Arduino drivers (comes with the IDE) and connect the board to the arcade PC via USB.
12. Open Device Manager and find the COM port that the board uses.
13. Edit the COM number in the following script and save it somewhere as a .cmd file (for example "c:\scripts\ir_script.cmd"):
Code: [Select]
powershell $port=new-Object System.IO.Ports.SerialPort COM3,9600,None,8,one;$port.open();$port.WriteLine(\"A\");$port.close()(I'm using a cmd file to call powershell, to avoid messing with the execution policy restriction, and because windows startup\shutdown scripts does not run ps scripts.. or at least it didn't for me)
14. Point the IR LED to the TV, and run the script. Hopefully the TV will turn off :)
15. Enter the computer's group policy editor (gpedit.msc), and go to Computer Configuration -> Windows Setting -> Scripts (Startup/Shutdown)
16. Edit the properties for both scripts, and point it to the above script (c:\scripts\ir_script.cmd).
17. It seems that the script do not run on shutdown and starting from shutdown state (as opposed to restart) when Hibernation is enabled. To disable it run as administrator the command:
Code: [Select]
powercfg /h offNote that windows update may turn hibernation back on.. so pay attention :)

Some extra information can be found here:
https://learn.sparkfun.com/tutorials/ir-communication


I couldn't find in the forums anyone that came up with the same solution as I did, so here it is :) .


ivwshane

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1036
  • Last login:December 24, 2022, 09:35:21 pm
    • My first mame cab! (WIP)
Re: Using Adruino as Remote Control to turn TV on/off automatically
« Reply #1 on: April 08, 2018, 01:47:47 pm »
Thanks for the post!!

I haven't had to use this yet as every TV I've used so far has had a "power on after power loss" function but this could be used for this screens that don't have that.

processedmeat

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 245
  • Last login:March 18, 2024, 06:49:22 pm
  • Ikeakade Here I come!
Re: Using Adruino as Remote Control to turn TV on/off automatically
« Reply #2 on: April 11, 2018, 04:22:46 pm »
Thanks OP for the helpful post.  FYI on some TVs the "Power On After Power Loss" is also masked as "Store Demo" mode. 

a_netanel

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 18
  • Last login:August 28, 2022, 11:40:07 am
  • I want to build my own arcade controls!
Re: Using Adruino as Remote Control to turn TV on/off automatically
« Reply #3 on: April 11, 2018, 04:27:18 pm »
Thanks.
But even if the TV supported "Power On After Power Loss", what I wanted to achieve is a behavior similar to a computer monitor. I don't cut the power to the cab altogether, just turn off the PC.

processedmeat

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 245
  • Last login:March 18, 2024, 06:49:22 pm
  • Ikeakade Here I come!
Re: Using Adruino as Remote Control to turn TV on/off automatically
« Reply #4 on: April 12, 2018, 04:40:56 pm »
Yes, I forgot to mention that this goes hand in hand with one of those energy saving power strips.  When I turn on my PC, the TV gets juice from the strip and turns on via the Power On After Power Loss or Store Demo feature.