In this article we are programming the basic stamp to trigger a remote switch for your home lights or any other power switching device, like a garage door, fireplace and so on. We are controlling it through the web or the ipod (the ipod also has a web browser)
How does it work?
After programming the basic stamp, it looks for a specific variable; when it receives this variable we are putting a current on the output pin of the basic stamp. The current switches a relay, this closes the electronic circuit of the remote “klikaan klikuit” transceiver. The variable, where it all starts with, is send through the serial / usb port by a single web page.
Shopping list:
- Micro controller Basic Stamp http://www.parallax.com
- Breadboard 6″ board (not necessary)
- DC power supply 5-9 V or regular 9V battery
- 5V DC voltage regulator
- 220 Ohm resistors 1/4 watt
- Two TIP 122
- (stiff) wires
- two* 9-pin D-sub female
- two* gender changers
- two* USB-to-serial adapter including mini gender changer (if you don’t have a serial port)
- two* serial connection cable (not a null-modem cable!)
- some 5V relays (minimal of two, depending on the connections you want to make)
- similar klikaan klikuit tranceiver.
- similar klikaan klikuit receiver.
NOTE: *This project can be done by using a one serial cable setup. This is not recommended, you really don’t want to to switch your cables every time..
Making the scheme:
its all coming together when you’re making your test board. Connect the components by the following scheme. See the image for better understanding of the scheme.
First we look at the end result, this drawing will explain the parts:

here is a technical drawing of the wire connections..
Programming the basic stamp chip
Now before we can start programming we need to download a free basic program from parallax.
follow the link for win or mac installers: http://www.parallax.com/ProductInfo/Microcontrollers/BASICStampSoftware/tabid/441/Default.aspx
Once installed we can setup the program.
before we can go further we need to connect the serial cable and must know on which (COM) port it is connected. (for example: look at my computer -> preferences ->hardware config.)
We are connected to com port 14
Now connect the serial cable and power to the micro controller and launch the program.

1) Choose the basic stamp 2 code setup
2) Add pBasic language to version 2.5

3) change the port setting to your com port, in our example this is port 14.
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM14}serData VAR Byte(10)
Main:
SERIN 7, 16468, [WAIT("123"), serData]
IF serData = 65 THEN
GOSUB LichtAan
ENDIF
IF serData = 66 THEN
GOSUB LichtUit
ENDIF
GOTO main
LichtAan:
HIGH 8
PAUSE 1000
LOW 8
RETURN
LichtUit:
HIGH 9
PAUSE 1000
LOW 9
RETURN
this code will be constantly running on the chip and will wait for the incoming data 123, When 123 passes it will be looking for the next Byte. In our case we will be sending the data 123 followed by A (representing ON) or B ( representing OFF) . So when we send the data 123A the chip has encountered the ‘A’ in ASCII DEC language this is 65. The char ‘B’ is 66, you get the point..
For a nice overview of the ASCII codes look here.
Installing a local server:
Now we need to set up a local server like wamp (For linux, any LAMP like setup will suffice). Why? This because we need a PHP page that sends the variable to the COM port. In our example sending data to the COM port will be done directly through PHP.
Setting up the pages and code..
We are using wamp for windows. If your using a other operating system use Lamp (linux) or Mamp (mac).
Download wamp
The installation wizard is really easy, just click next and next
We don’t need to configure it (for now).
When wamp is running you will be seeing a small speedometer icon in you task bar..
Creating the PHP file (not yet ready for ipod use!):
- Note! Make sure you set your com port correct!!
Here is the iPod friendly code:
And of course you can control the light trough the ipod by accessing the php code on the ipod Touch / iphone.
Just access your local server in your wireless home network, it should be similar to 10.0.0.15x

Download the files
This Zip package contains all the needed files to make the above application!







6 Comments at "Homecontrol using the basic stamp - Web or iPod controlled"
[...] Home automation with the Basic Stamp - Link [...]
Waarom zo moeilijk:
http://gathering.tweakers.net/forum/list_messages/1077675
Een 433mhz zender en (win)lirc en je bent klaar voor alle knoppen.
[...] http://www.labcoding.com/generic/homecontrol-using-the-basic-stamp-web-or-ipod-controlled2/ [...]
Hi Martijn,
is it possible that you contact me in ICQ? I’m from germany and have no idea where to get this basic stamp thing, but if you could build me for money this little board, i will be really happy

I have a car-pc integrated in my car and it would be amazing to control windows, lights, engine and so on with this gadget
my icq uin: 142050088
Thank you, reading your post i finally managed to remote control my stamp. Thanks for the information!
Hi Brian, At this point i must dissapoint you. I do not have the time to get started at another project. We have a lot of project on our minds now. Soon this project will be explaind on this blog! Alhough, to get started with the basic stamp i would suggest you take a look at: http://www.robotwinkel.nl this is a dutch store that sells the basic stamp, this will be much cheaper than order it in america. (if you cant find a store that sells the basic stamp in germany this is probably the best option). Offcourse we would like te hear how your project is going and what you have made!
Comment Now!