Controlling Alpha LED Signs with Perl or PHP in Windows

October 13, 2008 – 10:02 pm

I acquired an Alpha LED sign in a '$1 it's broke' Ebay action. Using my undergrad EE skills, I replaced the fuse and had a working sign.

led_sign.jpg
(Also note some of my totally awesome collection of Internet Appliances)

Thing is, I have nothing to use it for. I was going to make it web accessible so random people could change the message, but that would require me to leave my computer on all of the time and my bandwidth free.

It's a easy project really. You need a form to collect the messages and place them in a database. Then you need another script that runs every X minutes, grabs the oldest unsent message from the DB and sends it to the sign. Then you snap a webcam photo. %90 of that code is in the PHP script below.

All of the real work for sending messages to the sign was done by this guy. He even has instructions on how to make the serial cable for the sign. All I did was figure out how to get at the serial port in Windows. It took a bit of mad Googling.

Perl:

 
#!C:\Perl\bin\wperl.exe
 
$com_port = 'COM1';
 
$style = $ARGV[0];
 
if($style eq 'flash') {
  $stlye = 'c';
}
elsif($style eq 'random') {
  $style = 'd';
}
elsif($style eq 'scroll') {
  $style = 'a';
}
elsif($style eq 'random') {
  $style = 'd';
}
elsif($style eq 'shrink') {
  $style = 't';
}
else {
  $style = 'a';
}
 
$message = $ARGV[1];
if(!$message) {
  $message = "Dude, my balls are freakin' huge.";
}
 
# LINUX: open( PORT, ">/dev/ttyS0" )
open( PORT, "+>COM1" ) or die "Can't open COM1: $!";
print PORT "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
print PORT "\001" . "Z" . "00" . "\002" . "AA" . "\x1B" . " $style " . $message . "\004";
close(PORT);
 
print "Sent: $message\n";
 

PHP:

If you're the brave sort, you can call this from a browser. It uses VFW Grab to snap a webcam picture after the message is displayed.

 
<?PHP
$style = 'w';
$message = (isset($_GET['message']) ? $_GET['message'] : 'Boobs?');
 
// LINUX: $fh = fopen("/dev/ttyS0", "wb") or die("can't open port");
$fh = fopen("COM1", "wb") or die("can't open port");
fwrite($fh, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
fwrite($fh, "\001" . "Z" . "00" . "\002" . "AA" . "\x1B" . " $style " . $message . "\004");
fclose($fh);
 
system("VFWGrab.exe");
print "Sent: $message";
print "<br><img src=capture.jpg>";
?>
 

On another note, a stick bug was being sticky in my garden this morning.
stick_bug.jpg

Post a Comment



thevedic.net

Part of the thevedic.net.
[Contact Me] - [Mud Emporium] - [Ozark, AR] - [See my Port?]

This site is in no way represents the opinions or positions of any company or organization including those who employ the creators of this web site. We're not responsible for the content, posts, responses by other users or ideas of any sites that are linked to on this page. This site is recommended for ages 18 and up.

VEDIC VEKO IS PROSPEROUS

Arkie Imports | Dean Vaughan | Dean Vaughan | K. Dean Vaughan | Kenneth Vaughan | Pig Trail 23 | Pig Trail Pics | See My Port Forward Info | See My Port Forward Info


I'm not affiliated with the following in anyway.
Arkansas MMA - Inferno Mixed Martial Arts - Inferno Martial Arts Club - Inferno Martial Arts Club - Official Inferno Fight Gear - Inferno Fight Equipment - Inferno Combat Gear - IFC Online - Inferno Fight Gear - Inferno MMA - Inferno Fight Gear