Friday, February 13, 2009

Epoch win! Happy 1234567890.

On Friday the 13th on Feb 2009 at 23:31:30 GMT human time, Unix time hit 1234567890.

Unix time is measured in the number of seconds elapsed since January 1st, 1970 (Midnight Coordinated Universal time (UTC)

Thursday, February 12, 2009

Net Neutrality

It's not often I get to do a highschool school project on something I am interested in. I made this video, with some friends, for my global issues class. It came out pretty good for an all-nighter.

A special thanks to Burnsy for staying up to record and ftp narrations to me on the fly.

Saturday, February 7, 2009

Internet Controled Car v1 BASIC Stamp

Update: I found a better way to do this using a parallel printer port instead, I recommend that instead of using a BASIC Stamp.

The BASIC Stamp microcontroller is a neat little device to play with and very simple to program. It can also handle RS232 serial data. With a little flash actionscript, some very simple PHP, and an Ubuntu Linux server I modified an RC car so that it could be driven from anywhere on the internets.

This is how it works:
The client program, written in Flash Actionscript, detects if an arrow key is down or up and sends the appropriate ASCII character to a PHP server side script, using the sendAndLoad function and the POST method. The PHP script takes that ASCII character, for example capital W for forward, and writes it to the com server’s com port.

Flash controler code:
I'm sure this is very possible to do in Javascript, instead of flash Actionscript. If anyone wants to post a Javascript version in the comments I would be happy to add it to the article.


Sending data through a com-port is really easy in Linux. The com-port is treated as a file and can be written to by a PHP script. The com-port “file” is located in “/dev/ttyS0”; ttyS0 is com-port 1, ttyS1 would be com-port 2, etc.
PHP Script

This “writes” your command variable to the servers com-port. To make the comport writable by everyone execute the following command,
sudo chmod a+w /dev/ttyS0

Serial Cable:

To make the RS232 cable I took a 9-pin com port female connector and a USB cable wire and solderd pins 2, for receiving data, 3, for transmitting data, and 5, for ground. For the car I don’t really need to receive data, as I am only interested in transmitting commands to it, so really you only need pins 2 and 5.

Input to the BASIC Stamp:

The next step is to take the RS232 output and put it into a BASIC Stamp microcontroller. But before you do this you must convert the RS232 +/- 12v signal into a +5v signal for the microcontroller to handle the input. To do this you need a MAX232 chip to build a UART circut (a quick google search can tell you how to build one). To take an input from, in my case, port 0 you say

cmd VAR Byte
SERIN 0, 84, [cmd]

Then whatever ASCII character is put in is saved in “cmd”. You can then turn on and off other ports depending on what cmd is.


Now that we can turn pins high and low, depending on what arrow key is pressed on the first controller program, we can turn on transistors. I have my transistors click on a “double pole, double throw” relay. I crakced open the RC car controller and had the relays make the proper connections to make the car go forward, back, left, and right (replacing what was once the mechanical connecters of the sticks).

So say we want the car to go forward, ASCII character capital W mapped to the up arrow key. When the BASIC Stamp gets this character it makes P1 go high and turns on the transistor which then turns on the relay. The relay makes the proper connection on the RC Car’s controller circuit to go forward. When the up-arrow comes back up the client program sends a lower case w turn the relay off. Same for back, left, and right.

Now you can set up a webcam to see the car and drive it around from anywhere in the world. This concept can be used to control anything you want over the Internet.