Pages: [1]   Go Down
Author Topic: TV control via LAN  (Read 2178 times)
0 Members and 1 Guest are viewing this topic.
South Louisiana
Offline Offline
Full Member
***
Karma: 0
Posts: 180
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

#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:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

  Serial.begin(9600);
  Serial1.begin(9600);

}

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

    // read the packet into packetBufffer
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    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());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}




* tv_control.jpg (64.17 KB, 486x828 - viewed 41 times.)

* IMG173.jpg (766.82 KB, 2592x1944 - viewed 78 times.)

* IMG175.jpg (1040.1 KB, 2592x1944 - viewed 90 times.)
* TV_Control_Processing.zip (544.1 KB - downloaded 26 times.)
« Last Edit: July 04, 2012, 05:36:19 pm by Goofballtech » Logged

Melbourne, Australia
Offline Offline
Jr. Member
**
Karma: 3
Posts: 79
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


South Louisiana
Offline Offline
Full Member
***
Karma: 0
Posts: 180
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

South Louisiana
Offline Offline
Full Member
***
Karma: 0
Posts: 180
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

https://forum.processing.org/topic/apwidgets-clickable-image


* TV Control.JPG (48.13 KB, 375x680 - viewed 31 times.)
* TV_Control.apk (823.45 KB - downloaded 16 times.)
Logged

South Louisiana
Offline Offline
Full Member
***
Karma: 0
Posts: 180
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

* ImageButton.pde (2.21 KB - downloaded 10 times.)
* TV_Control.ino (2.28 KB - downloaded 12 times.)
* data.zip (636.28 KB - downloaded 18 times.)
* TV_Control_Note.pde (9.4 KB - downloaded 13 times.)
« Last Edit: September 08, 2012, 10:37:22 pm by Goofballtech » Logged

Pages: [1]   Go Up
Jump to: