|
Objective
Think up an ambient display idea and
prototype it using Handy Cricket. The
demonstration must make some kind of TCP
connection to an existing Web Server,
parse the data received from the server,
and then create some kind of
tangible/kinesthetic/audible/etc
representation of this on-line data.
Design
I started the lab not knowing what
technologies I was going to use and to
what extent. First I needed to access an
existing web server to retrieve some
information. I decided to get the local
temperature from a local weather website.
After spending days analyzing what
programming language I was going to
utilize towards this goal, I decided to go
with Perl scripting language for its web
access capability and also for its great
parsing ability.
The main part of the code was written in
perl, file
temper.pl. This code makes a call to
curl to access a web page and store it
onto a file. The file is then parsed for
the temperature data. This temperature
data dictates what value to send to the
serial port connected to the cricket. The
actual code that does the serial port
communication is written in C, file
serial.c, with its executable named
swr.exe. This serial code is called from
perl, where a value is sent to the
cricket.
The cricket code is written in cricket
logo and found in
tdir.txt. All it does is wait for a
value of 6, and once received changes the
direction of the motor rotation which is
connected to the cricket. The motor is
attached to a wheel which turns in free
space. What the wheel turning actually
indicates is the change in temperature or
directionality of temperature change. Thus
if consecutive temperature reads have
increasing value the wheel turns one way
and for decreasing values the wheel turns
the other way. This basically notifies the
user whether the temperature is warming up
or cooling down at any point in time.
The actual calculations on the temperature
values is done in the perl code and only
when the temperature changes direction
does it send a message to the cricket to
reverse direction of the wheel. I found
this to be a very interesting application
as one may want to know which way the
temperature is heading.
|