Go Down

Topic: TV control via LAN (Read 3750 times) previous topic - next topic


Jul 01, 2012, 07:27 pm Last Edit: Jul 05, 2012, 12:36 am by Goofballtech Reason: 1
I recently got a really good deal on a LC-70LE732U Sharp TV. I saw on the box it had all the "Smart TV" apps but was delighted to find out it had a Serial port for control. I was even more happy when i realized it can be controlled via ethernet.... but this bubble burst when i realized a username/password was needed each time and only one client can Winsock at any one time for control.

So i moved back over to the serial connection.

I have been looking at doing Ethernet control for a little while because i will be building a little Ethernet controlled submarine soon so i figured this would be a good project to get my feet wet on UDP.

What i did was put an Ethernet Shield on a Mega. Build a little shield for the other side of the board that contains a max232 and it's supporting components as well as a DB9 female.

As my first functional project with processing i took the easy way out and used the G4P GUI builder for buttons and made a PC interface. The PC interface creates a UDP string and sends it to the ethernet shield on the Mega. The Mega will use that to create a serial string and output that to the TV through the MAX232.

I have a few more things i want to do as well.

1. Create a green flash driven by the OK reply from the TV when a good command is recieved and a red flash that would be the result of an ERR reply when command did not get processed.

2. Create an APK from the little app so i can use my phone to control my TV as long as i am connected to the LAN.

3. Make the app a few pages so i can have one page of each set of buttons on the actual remote. (ex. number pad, DLNA controls, Menu/Options, etc.)

As of now things are working great from the PC. Now my challenge is to get this app ported over to Android.

Code isn't very hard. I did keep some of the stuff from the UDPSendRecieve example and modded it for my purpose.

Added .zip file for processing so it has all the dependent files for the basic controller.

Arduino Code:

Code: [Select]

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {  
 0x90, 0xA2, 0xDA, 0x00, 0xA5, 0xC4 };
IPAddress ip(192, 168, 5, 200);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
 // start the Ethernet and UDP:



void loop() {
 // if there's data available, read a packet
 int packetSize = Udp.parsePacket();
   Serial.print("Received packet of size "); //Print Packet Information to USB/Serial Port
   Serial.print("From ");
   IPAddress remote = Udp.remoteIP();
   for (int i =0; i < 4; i++)
     Serial.print(remote[i], DEC);
     if (i < 3)
   Serial.print(", port ");

   // read the packet into packetBufffer
   Serial.println(packetBuffer); //Print contents of packet to USB/Serial for Debug

   Serial1.println(packetBuffer); //Print contents of packet to Serial1 (connected to MAX232 -> TV Serial Port)

   // send a reply, to the IP address and port that sent us the packet we received
   Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());


That's a great idea. Have you documented your project anywhere?


Pretty much on here. lol.

It's still being worked on. The interface is still very basic, I intend to make it pretty much a whole remote on the PC then as mentioned a few pages on android. I will post my code on here as it progresses.


Got a few updates on my little project. I have successfully gotten the PC and android app working with some help from the processing forum for the android stuff.

I have attached a screen shot of the current PC based controller.

The android based one looks pretty close to the same without the text box for channel entry. I have an android one for 480x800 resolution (Wife's HTC Inspire) and 800x1280 (My Galaxy Note).

The android stuff is java based, it was pretty close to the C++ i know from arduino coding but took a bit of getting used to for the classes and all that which i have never used much.

Android code here...



Sep 09, 2012, 05:33 am Last Edit: Sep 09, 2012, 05:37 am by Goofballtech Reason: 1
Got some more fun with my app. Set it up to control via WAN or LAN on the android app.

Hopefully someone can get some use. Maybe even add some features.

Maybe chevellejnj72 can add a couple buttons that move the TV. My TV moves too.... so let me know if you do!

Go Up