SpriteHand
Module Border
  By Your Command
Module Border
Location: BlogsAndy's Blog    
Posted by: host 12/1/2006 9:15 AM

Controlling stuff from a web page is really cool. By stuff, I mean stuff in the real world, like lights, household appliances, or perhaps... killer robots.

While it's still tough to find an affordable automaton in the "killer robot" category, there are some fairly inexpensive alternatives like the version 1.0 Robosapien. This model is a bit less expensive because the Robosapien Version 2.0 is now the hot item for Christmas.

These robots are controlled via an Infrared remote, much like your TV or cable box. So how do we go about controlling Infrared devices from our PC using .NET?

STEP 1: Get an IR Blaster
First your PC needs a device to transmit IR signals. You can certainly build your own IR transmitter, but I found that for just $12, you can get a very good quality device from
www.irblaster.info.

Here is what the $12 device looks like. It has a basic DB9 Connector to fit into an available COM port:

STEP 2: Setup WinLIRC
WinLIRC is an open source program that allows you to transmit and receive infrared remote signals. When you run WinLIRC, you get a config dialog where you select the COM port that your IR transmitter sits on.

Notice the "Config" textbox at the bottom. WinLIRC works off config files which store remote code information for different devices. There is an extensive database of remote codes already available for a whole bunch of IR devices.

For the Robosapien, Eric Buehl created a compatible config file as part of a project. You can download his config file here

Once you download your config file and enter it into the WinLIRC configuration screen, you can select OK.

Now you will be at the WinLIRC test screen. Here you can select a remote (defined in your config file) and send a code to the IR device. I call this a "test screen" because that's all its really good for - making sure that your IR Blaster and config file are all working happily.

Is it working? Is your PC making the device do stuff? Cool, then you can click the "Hide Window" button which will make WinLIRC disappear into your system tray and appear like a little virtual LED light:

 

STEP 3: Using WinLIRC as a Server
Using the WinLIRC test screen is fun and all, but we want to control our IR device from some .NET code! To do this, WinLIRC provides a telnet server which we can communicate with on TCP port 8765.

To test the telnet server you can open a command prompt and type:

telnet 127.0.0.1 8765

...after which you will be logged into the WinLIRC telnet service. There are a few basic commands you can type here, such as:

LIST                             
(gives a list of available remotes from your config)

LIST [REMOTE name]  
(gives a list of remote codes available on a remote)

Now, to send an actual IR command, there is some security in place here. After all, this is a telnet server and if you are not behind a firewall, any lame hacker could come in and start using your killer robot against you!! 

So to send IR codes through the telnet server, we need to add a password to our registry. Run Regedit and go to the HKEY_LOCAL_MACHINE\SOFTWARE\LIRC node. Add a new String value named password with the value of a password:

Now, in a telnet session, you can use a command to send IR signals in this format:

[PASSWORD] [REMOTE] [CODE] [# repeats]

For example, to have my SONY-TV change to channel 4, I would use the command:

password SONY-TV 4 1

STEP 4: Using the WinLIRC Telnet Service from .NET
.NET makes a lot of things easy, including Telnet! To perform a telnet session to the WinLIRC server and send a command, the code is short and sweet:

TcpClient client = new TcpClient("127.0.0.1", 8765);

Stream s = client.GetStream();

StreamWriter sw = new StreamWriter(s);

sw.AutoFlush = true;

sw.WriteLine("password SONY-TV 4 1");

sw.Close();

s.Close();

client.Close();

NEXT STEPS
Oh, so much to do! We could create an ASP.NET page to send whatever IR codes we want to our household appliances! We could create a queuing mechanism so that multiple users could submit commands to the devices simultaneously! We could create an army of Robosapiens equipped with Lasers and control them all from the comfort of our keyboard.

Permalink |  Trackback

Title:
Comment:
Add Comment   Cancel 
Module Border Module Border
Module Border
  Subscribe
Module Border
RSS   Twitter
Module Border Module Border
Module Border
  Diversions
Module Border


PHYSAMAJIG
This Windows app was created using Physics Helper XAML, and the Farseer Physics Engine.
DOWNLOAD

MORE INFO



TALKING RAGDOLL
This Windows Phone app was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine. It gets interesting when you import your friends photos and have your way with them!

MORE INFO



BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight , the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2014 andy.beaulieu.com - Login
toms outlet cheap toms jordan pas cher Timberland Boots mulberry outlet portafoglio prada hollister soldes hogan scarpe mbt hogan jordan pas cher louboutin soldes jordan Homme louboutin pas cher Gucci Borse louboutin pas cher jordan pas cher lancel pas cher cheap ray ban sunglasses ray ban outlet toms outlet toms outlet scarpe mbt occhiali da sole a basso costo Louboutin Chaussures basket louboutin hollister pas cher jordan shoes sale