31.5.09

more making things - clouds

My hands are going to be wrecked by the end of this week. This weekend I have been putting the final touches to my clouds, amongst other things, which I will blog about later.

After putting the knitting together to at least partially look like a cloud, I got the vibe boards ready to sew into the clouds. I've been using scraps of material to hold each of the components, so it can be put together like a puzzle, which is nice and easy.



I've placed the vibe boards on the back of the clouds, so while the user is holding it they can feel the vibe better. Here's me placing it...



And it sewn in...



I then worked on the little sun for the partially sunny cloud, finishing off the back of the circuit and sewing it up.



Here he is all poofy and ready to be sewn in. The threads sticking out of him are conductive threads, ready to feed into the cloud to continue the circuit for the vibe board up to the little sun.



I then used some more scraps to make a little path for the conductive thread to go along inside the cloud.



Put the sun where I wanted him, and sewed him in.



I then tested him to make sure that he still worked, here's me attaching a temporary power source to test it.



I then connected the little sun circuit down to the vibe board circuit, and tested it all again..



'ello!



Now I just need to stuff him and put the RFID card in. The RFID reader was being a little temperamental last night but seems to be working now, hopefully will still be working for the exhibition.

29.5.09

Arduino workshop



Today I tottered off to a tinker.it workshop at old broadcasting house in Leeds, and it was immense. I learnt about the history of the arduino, which is funnily enough named after a pub. And how to make circuits with the big boy arduinos, the one I was given today was a Duemilanove, which seemed complex compared to the little lilypads I'm used to. So many holes to put things in, and analog and digital input go in two different places which seemed weird. Most of the day was spent making circuits for some of the different example codes that come with the arduino programming environment, which I was grateful for as the circuits seemed very different to what I make with the lilypads. I learnt how to use a breadboard to do prototyping, and got a little bag of toys!!

The above circuit is for the button example. I'm suprised how easy it is to prototype with it.

I'm glad i went, using a different arduino board with proper wires seemed a bit daunting. Shame that there's only a week left on my project. I feel like I'm a step closer to hacking stuff instead of making it from scratch.

28.5.09

oh yeah...

Here's some of the visual elements I will be using in my final piece.

Partly Cloudy



Heavy Rain



Sunny



Light Rain



Cloudy



These will be mixed up with some other elements, along with some text telling you the city and some other info. Based on the sketches I made when thinking things through in my sketchbook.

27.5.09

making things

Over the past week I have finally finished my knitting, been aggravated by conductive thread, and been testing LEDs.

I finally finished knitting my raindrops, and created the pouch to make the raindrop shape, and stuffed an RFID card into it.



Here is one of my raindrops, with my cloud who now has eyes. The raindrops aren't completely finished, I've left the bottom open so I can put some LEDs in them, and hook them up to a lilypad, but the basic shape is there.



I also worked on my sun a lot. Once the LEDs were put through I made the circuit with conductive thread, and tested it by temporarily adding a power source. Some of the LEDs are a little temperamental but do work.



This is the finished sun circuit. I've covered the back of the LEDs so they don't get caught up in the stuffing.



I'm also making a little sun, which will be attached to a wooly cloud to represent "partly cloudy". I've decided to put some LEDs into this one as well, as the bigger sun was relatively simple to do.



Here is the big sun partly sewn together and stuffed. The bottom has been left open so I can connect it to a lilypad later. My idea for using the LEDs is to get them to blink or flash when the RFID reader reads the appropriate card.

22.5.09

RFID controlled weather feed

it works and it's so glorious.

The one thing is that it waits till the feed is brought in again before it tells you the weather feed, it isn't instantaneous. At the moment my feed comes in every five seconds which i thought was quite a lot. It would be nice if i could get it looping rather than just waiting. maybe loop(); will work. starting to think about how it's all going to look visually as well...


//weather for twelve cities!
// now waiting for button presses from lilypad
//trying to make it learn to shut up

// XML stuff
import simpleML.*;

// Serial stuff
// import the serial library:
import processing.serial.*;

Serial myPort; // the serial port you're using
String tagID = ""; // the string for the tag ID

XMLRequest aberdeen;
XMLRequest aberystwyth;
XMLRequest birmingham;
XMLRequest bristol;
XMLRequest dundee;
XMLRequest leeds;
XMLRequest liverpool;
XMLRequest london;
XMLRequest manchester;
XMLRequest newcastle;
XMLRequest oxford;
XMLRequest reading;



int startTime; //create timer
int counter = 0;


void setup() {
size(200,200);


// list all the serial ports:
println(Serial.list());

// based on the list of serial ports printed from the
// previous command, change the 0 to your port's number:
String portnum = Serial.list()[0];
// initialize the serial port:
myPort = new Serial(this, portnum, 9600);
// incoming string from reader will have 16 bytes:
myPort.buffer(16);

// create a font with the second font available to the system:
PFont myFont = createFont(PFont.list()[2], 24);
textFont(myFont);

//create and start up request

aberdeen = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0001&u=c");
aberdeen.makeRequest();

aberystwyth = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0203&u=c");
aberystwyth.makeRequest();

birmingham = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0018&u=c");
birmingham.makeRequest();

bristol = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0025&u=c");
bristol.makeRequest();

dundee = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0045&u=c");
dundee.makeRequest();

leeds = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0078&u=c");
leeds.makeRequest();

liverpool = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0083&u=c");
liverpool.makeRequest();

london = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0085&u=c");
london.makeRequest();

manchester = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0092&u=c");
manchester.makeRequest();

newcastle = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0098&u=c");
newcastle.makeRequest();

oxford = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0106&u=c");
oxford.makeRequest();

reading = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0117&u=c");
reading.makeRequest();
startTime = millis();//more timer stuff



}

void serialEvent(Serial myPort) {
// get the serial input buffer in a string:
String inputString = myPort.readString();
// filter out the tag ID from the string:
tagID = parseString(inputString);
}

String parseString(String thisString) {
String tagString = ""; // string to put the tag ID into

// first character of the input:
char firstChar = thisString.charAt(0);
// last character of the input:
char lastChar = thisString.charAt(thisString.length() -1);

// if the first char is STX (0x02) and the last char
// is ETX (0x03), then put the next ten bytes
// into the tag string:

if ((firstChar == 0x02) && (lastChar == 0x03)) {
tagString = thisString.substring(1, 11);



}
return tagString;
}

void draw() {
background(0);

//every 5 seconds, make new request
int now = millis();

if (now - startTime > 5000) {
aberdeen.makeRequest();
println("1");
}

if (now - startTime > 5000) {
aberystwyth.makeRequest();
println("2");
}

if (now - startTime > 5000) {
birmingham.makeRequest();
println("3");
}

if (now - startTime > 5000) {
bristol.makeRequest();
println("4");
}

if (now - startTime > 5000) {
dundee.makeRequest();
println("5");
}

if (now - startTime > 5000) {
leeds.makeRequest();
println("6");
}

if (now - startTime > 5000) {
liverpool.makeRequest();
println("7");
}

if (now - startTime > 5001) {
london.makeRequest();
println("8");
}

if (now - startTime > 5000) {
manchester.makeRequest();
println("9");
}

if (now - startTime > 5000) {
newcastle.makeRequest();
println("10");
}

if (now - startTime > 5000) {
oxford.makeRequest();
println("11");
}

if (now - startTime > 5000) {
reading.makeRequest();
println("12");
startTime = now;
}


}


//when request is complete
void netEvent(XMLRequest ml) {

String city = ml.getElementAttributeText("yweather:location", "city");

String temp = ml.getElementAttributeText("yweather:condition", "temp");


String weather = ml.getElementAttributeText("yweather:condition","text");



while(tagID.equals("2100764B24")) { // PARTLY CLOUDY --------------------------------------

if (weather.equals("Partly Cloudy")) {
println("it is partly cloudy in " + city);
break;
}

if (weather.equals("Partly Cloudy/Windy")) {
println("it is partly cloudy and a bit windy in " + city);
break;
}
else {
println("not a little bit cloudy " + city);
break;
}
}

while(tagID.equals("2100766B22")) { // CLOUDY --------------------------------------

if (weather.equals("Cloudy")) {
println("it's cloudy in " + city);
break;
}

if (weather.equals("Mostly Cloudy")) {
println("it's mostly cloudy in " + city);
break;
}

if (weather.equals("Mostly Cloudy/Windy")) {
println("it's mostly cloudy and a bit windy in " + city);
break;
}
else {
println("it's not cloudy in " + city);
break;
}
}

while(tagID.equals("210076572B")) { // LIGHT RAIN --------------------------------------

if (weather.equals("Light Rain")) {
println("it's raining lightly in " + city);

}

if (weather.equals("Light Rain/Wind")) {
println("it's raining lightly and a bit windy in " + city);
break;
}

if (weather.equals("Light Rain Shower")) {
println("there's a light rain shower in " + city);
break;
}

if (weather.equals("Showers in the Vicinity")) {
println("there's some rain showers near " + city);
break;
}
else {
println("it's not raining lightly in " + city);
break;
}

}

while(tagID.equals("21007643E3")) { // RAIN --------------------------------------

if (weather.equals("Rain")) {
println("it's raining in " + city);
break;
}

if (weather.equals("Rain/Wind")) {
println("it's raining and windy in " + city);
break;
}

if (weather.equals("Few Showers")) {
println("there's rain showers in " + city);
break;
}
else {
println("it's not raining in " + city);
break;
}

}
while(tagID.equals("21007683C0")) { // SUNNY --------------------------------------

if (weather.equals("Sunny")) {
println("it's all nice and sunny in " + city);
break;
}

if (weather.equals("Fair")) {
println("it's nice and fair in " + city);
break;
}

if (weather.equals("Moslty Sunny")) {
println("it's mostly sunny in " + city);
break;
}

else {
println("it's not sunny in " + city);
break;
}

}


}

21.5.09

hurrah.



My USB connector for my RFID reader is here, and I've got it working relatively quickly. My reader is an ID-20, slightly different to the reader in "Making Things Talk", which is an ID-12, but the only difference seems to be the range it will read at (the ID-20 is a little stronger). I've used the example code from Making things talk to get it working in Processing, and I've now been able to give the cards their names!!

Maybe little 21007683C0 will be rain.. I imagine it will be a simple case of replacing the button code I've been working on with the RFID code, and instead of it looking for button presses it will be looking for strings of characters. One thing with the reader is that it can't tell when a card is removed, just when it appears, so any kind of resting state with have to be done with a timer.. if that will work...

18.5.09

sun

Today I have been working on my sun. I have also done some knitting but the progress of that is not as interesting to document.

OMGZ I did like thirty more rows today that is loads LOLOLOLOLOL.

I'm getting a bit bored of the knitting so decided to do some sewing and work on my light emitting sun.

I cut out one white circle (using a bowl to get a nice round.. circle), and four yellow ones. I've decided to use two layers of yellow as the polycotton was actually quite thin, and I wanted it to be all bright and nice. I sewed the yellow bits together to make things a little easier on myself a bit later. The white layer is where the conductive thread will be, I left it loose at this stage.



I then figured out where I wanted to place the LEDs using pins to represent them. Two pins represents one LED. Using two was my pitiful attempt to make some holes for the legs of the LEDs to go through. The yellow looks so pale because my camera was freaking out at the brightness of it.



I then started putting the LEDs into place. This was painful. LEDs do not like fabric. Espesh three layers of it. I did master a technique using a pin to wiggle the legs through, some of the fabric got a bit pulled but I'm not that fussed. Anyone who mentions it will be forced to put an LED through three layers of fabric.



This is what it looks like with the LEDs in place. Now I'm on the stage where I'm making the circuit. Conductive thread hurts.



I guess I should work on some graphics. I don't want to. Graphics aren't fun. And if communication between processing and flash is done in the serial communication kind of way, the Signals from Arduino may cause interference... could use different channels but eugh.

17.5.09

forgetting things is sometimes good.

I remembered to order my RFID reader and some cards..



forgot to order the USB connector. *face palm*

So while I've been waiting for that to appear I've been working on my code, using a button based system. As any other tech I use will use the same basic way of working; something sending a signal, something waiting for a signal, and when that signal is received running the script which looks at the weather feed and spurts it out when necessary.

(Actually it works a bit more like this, pulling in the weather feed every five seconds or whatever, and saving it. Then waiting for a signal stating what weather the user wants to look at, looking at the saved weather feed, and spitting out the appropriate weather.)

I've been using arduino for this, programming my buttony lilypad to send a signal to processing. I was having a few problems at first, once the signal was sent it wouldn't stop sending it, or processing wouldn't stop reading it. New button presses weren't even registering, which confused me a bit. I did a bit of research and found out how to debounce buttons, and now it works. Once a button is pressed it will keep displaying that weather until a new button is pressed. I would like to make some kind of rest state, where if nothing is pressed something else happens, not sure how to do it, may involve timers in processing, sending a resting state from arduino just jams the signal for button presses.

That might not make sense to you, but makes perfect sense to me. Here's the arduino code I'm currently using:


// edited the example to use two buttons
//edited the example further t o send a signal to processing.
//and debounce code from http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241461190

int ledPin = 13; // LED is connected to digital pin 13
int switchPin = 2; // switch connected to digital pin 2
int switchPin2 = 5;
int switchValue; // a variable to keep track of when switch is pressed
#define BOUNCE_PERIOD 150

long last_read_time;
long last_value;

int val = 0;
int val2 = 0;

void setup()
{
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
pinMode(switchPin, INPUT); // sets the switchPin to be an input
digitalWrite(switchPin, HIGH); // sets the default (unpressed) state of switchPin to HIGH
pinMode(switchPin2, INPUT); // sets the switchPin to be an input
digitalWrite(switchPin2, HIGH); // sets the default (unpressed) state of switchPin to HIGH

Serial.begin(9600);
}

void loop() // run over and over again
{
// If we are past our bounce period
if (millis() - last_read_time > BOUNCE_PERIOD){

// Check the button
val = digitalRead(switchPin);
val2 = digitalRead(switchPin2);
// If the button has changed since last bounce period

if (val != last_value){
digitalWrite(ledPin,val);
if (val == LOW) Serial.print("A");
last_read_time = millis();
last_value = val;
delay(10);
}

if (val2 != last_value){
digitalWrite(ledPin,val2);
if (val2 == LOW) Serial.print("B");
last_read_time = millis();
last_value = val;
delay(10);
}
}
}


I've also been knitting my second cloud and light raindrop... the knitting never ends!!!!

14.5.09

fio's first futuresonic



Gave her a numb bum. Probably a bit too much information there, but oh well.

The eyes were also sore after looking at all the interesting things people we're talking about and visualizing with slides. Unfortunately, my little student pass only got me into the conference part of the festival, which saved me trekking around manchester, but limited the fun I could have. But I did see some interesting talks...

I had actually planned to see Usman Haque's talk on real time environmental data, which i'm a bit gutted at missing, but ended up seeing the digital futures talk which talked about next generation broadband as a disruptive technology which i like the idea of. This was followed by a talk by Phillip Trippenbach who disscussed the addictive aspect of games and why we should use them for good. And Toby Barnes discussed the social effect of games and their basis on western ideas of having lots of money and material weath meaning you are winning at the game.

I think i probably ended up in the wrong room in the morning, but I keep getting the feeling I was in the wrong place at the wrong time for much of the day, as something interesting was always going on somewhere.

For the afternoon I went to see Jonah Brucker-Cohen who discussed his rather interesting work, two pieces he discussed that I liked were his drill hit counter, which is a drill connected to a website, which creates physical damage to a real world building whenever the web page receives a hit, and the toy police cars controlled by terrorist keywords found in emails, using the same software as the American government. I especially liked the theme of real world reactions to events in the online world. I also saw the discussion about the site some one once told me, which was victim to the fail wireless network, but I still got some pretty schweet business cards.

Check out my new knitting bag, which actually has a cloud in it...

11.5.09

mmm buttons.

I've decided to look back into buttons, incase all the fancy RFID and wiimote trickery doesn't work. My backup idea is a simple button based system, with all the little toys or rather tactile bits wired up to a lilypad, with a boring button to press to send the signal, to see what the weather is like.



As I couldn't get ellie to work, I found a tutorial that tells you how to make switches. Turns out that one end of the button should connect to the - bit of the lilypad.



I've even got it working with two buttons, because I'm so clever!

10.5.09

fluffy little cloud

I did lots of knitting, making rectangles as i don't know how to knit any other shapes and created some little pouches to hold the cotton wool stuffing.



I decided to abandon the pouches and just stick the cotton wool in on it's own, and the pouches made it look a bit flat. I then sewed all the pieces together and here is my cloud!



Just needs a wiimote stuffed inside it and maybe a face. Because faces are nice.

from arduino into processing

is not as simple as I first thought it would be. This is for the light sensor I will be using in my final piece.

I've been trying two approaches, the first one getting processing to hijack the serial communication that the lilypad sends to arduino, to see the values the light sensor sends back. This was a bit weird, the values in processing were quite different and didn't make much sense, there didn't seem to be any correlation between the numbers I was seeing and the changes in light.

I've then been looking into firmata, which allows you to program the arduino board from processing itself, but this method recieved even stranger results, this time only printing out 0. It seemed to be receiving a signal from the light sensor but that was only to say that there was no light. I've found someone with a similar problem on the processing forum, so hopefully they'll be able to help me, but it's confusing me at the moment.

8.5.09

weather in twelve cities


//weather for twelve cities!

import simpleML.*;

XMLRequest aberdeen;
XMLRequest aberystwyth;
XMLRequest birmingham;
XMLRequest bristol;
XMLRequest dundee;
XMLRequest leeds;
XMLRequest liverpool;
XMLRequest london;
XMLRequest manchester;
XMLRequest newcastle;
XMLRequest oxford;
XMLRequest reading;



int startTime; //create timer
int counter = 0;


void setup() {
size(200,200);
//create and start up request

aberdeen = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0001&u=c");
aberdeen.makeRequest();

aberystwyth = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0203&u=c");
aberystwyth.makeRequest();

birmingham = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0018&u=c");
birmingham.makeRequest();

bristol = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0025&u=c");
bristol.makeRequest();

dundee = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0045&u=c");
dundee.makeRequest();

leeds = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0078&u=c");
leeds.makeRequest();

liverpool = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0083&u=c");
liverpool.makeRequest();

london = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0085&u=c");
london.makeRequest();

manchester = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0092&u=c");
manchester.makeRequest();

newcastle = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0098&u=c");
newcastle.makeRequest();

oxford = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0106&u=c");
oxford.makeRequest();

reading = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0117&u=c");
reading.makeRequest();
startTime = millis();//more timer stuff



}

void draw() {
background(0);

//every 5 seconds, make new request
int now = millis();

if (now - startTime > 5000) {
aberdeen.makeRequest();
println("1");
}

if (now - startTime > 5000) {
aberystwyth.makeRequest();
println("2");
}

if (now - startTime > 5000) {
birmingham.makeRequest();
println("3");
}

if (now - startTime > 5000) {
bristol.makeRequest();
println("4");
}

if (now - startTime > 5000) {
dundee.makeRequest();
println("5");
}

if (now - startTime > 5000) {
leeds.makeRequest();
println("6");
}

if (now - startTime > 5000) {
liverpool.makeRequest();
println("7");
}

if (now - startTime > 5001) {
london.makeRequest();
println("8");
}

if (now - startTime > 5000) {
manchester.makeRequest();
println("9");
}

if (now - startTime > 5000) {
newcastle.makeRequest();
println("10");
}

if (now - startTime > 5000) {
oxford.makeRequest();
println("11");
}

if (now - startTime > 5000) {
reading.makeRequest();
println("12");
startTime = now;
}


}


//when request is complete
void netEvent(XMLRequest ml) {

String city = ml.getElementAttributeText("yweather:location", "city");

String temp = ml.getElementAttributeText("yweather:condition", "temp");


String weather = ml.getElementAttributeText("yweather:condition","text");


if (weather.equals("Partly Cloudy")) {
println("Partly Cloudy" + city);

}

if (weather.equals("Partly Cloudy/Windy")) {
println("Partly Cloudy/Windy" + city);

}

if (weather.equals("Cloudy")) {
println("cloudy" + city);

}

if (weather.equals("Mostly Cloudy")) {
println("Mostly Cloudy" + city);

}

if (weather.equals("Mostly Cloudy/Windy")) {
println("Mostly Cloudy/Windy" + city);

}

if (weather.equals("Light Rain")) {
println("Light Rain" + city);

}

if (weather.equals("Light Rain/Wind")) {
println("Light Rain/Wind" + city);

}

if (weather.equals("Light Rain Shower")) {
println("Light Rain Shower" + city);
}

if (weather.equals("Rain")) {
println("Rain" + city);
}

if (weather.equals("Rain/Wind")) {
println("Rain/Wind" + city);
}

if (weather.equals("Few Showers")) {
println("Few Showers" + city);
}

if (weather.equals("Showers in the Vicinity")) {
println("Showers in the Vicinity" + city);
}

if (weather.equals("Sunny")) {
println("Sunny" + city);
}

if (weather.equals("Fair")) {
println("Fair" + city);
}

if (weather.equals("Moslty Sunny")) {
println("Mostly Sunny" + city);



}

}


Making progress :D

In the final code it will only refresh the RSS feed every few minutes, at the moment I'm keeping it in seconds so it's easier to see what's going on quickly.

i keep winning

It's rather strange. My ideas work. Here's my latest code, pulls in multiple weather feeds, in this case Leeds and London.


//woooooorks. weather in leeds & london

import simpleML.*;

XMLRequest leeds;
XMLRequest london;

int startTime; //create timer
int counter = 0;


void setup() {
size(200,200);
//create and start up request


leeds = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0078&u=c");
leeds.makeRequest();
london = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0085&u=c");
london.makeRequest();


startTime = millis();//more timer stuff
}

void draw() {
background(0);

//every 5 seconds, make new request
int now = millis();
if (now - startTime > 5000) {
leeds.makeRequest();
println("fio is epic");
}

if (now - startTime > 5001) {
london.makeRequest();
println("fio is awesome");
startTime = now;
}
}

//when request is complete
void netEvent(XMLRequest ml) {

String temp = ml.getElementAttributeText("yweather:condition", "temp");


String weather = ml.getElementAttributeText("yweather:condition","text");


if (weather.equals("Partly Cloudy")) {
println("Partly Cloudy");

}

if (weather.equals("Light Rain Shower")) {
println("Light Rain Shower");
}



}


Now all I need to do is populate the list with cities and different weather conditions.

7.5.09

even more little big win


//woooooorks.

import simpleML.*;


XMLRequest xmlRequest;

int startTime; //create timer
int counter = 0;


void setup() {
size(200,200);
//create and start up request
xmlRequest = new XMLRequest(this,"http://weather.yahooapis.com/forecastrss?p=UKXX0078&u=c");
xmlRequest.makeRequest();
startTime = millis();//more timer stuff
}

void draw() {
background(0);

//every 5 seconds, make new request
int now = millis();
if (now - startTime > 5000) {
xmlRequest.makeRequest();
println("fio is epic");
startTime = now;
}
}

//when request is complete
void netEvent(XMLRequest ml) {

String temp = ml.getElementAttributeText("yweather:condition", "temp");


String weather = ml.getElementAttributeText("yweather:condition","text");


if (weather.equals("Partly Cloudy")) {
println("Partly Cloudy");

}


}


It tells me that I'm epic, and that the weather in Leeds is Partly Cloudy.

little win

After a morning of trying to break HTML requests into strings and then into individual words, I have decided to abandon the BBC RSS feed and instead go with yahoo's less regularly updated one. Because the XML of the yahoo RSS feed looks like this:



Instead of the state of the weather being addressed in the description tag, almost each attribute of the weather is addressed in it's own little tag. Which makes it a lot easier to work with! It's what mister shiffman used in his script as well, so there's some documentation of how to use it well.

dirty XML

I've decided to look again at mister shiffmans simpleML library again, which I looked at briefly in my twitter top project, and found that not only am I a complete berk for not spotting the re-request HTML/XML command which I wanted so desperately and caused me annoyance when I couldn't figure it out myself, but that although it will save my program looking through the whole document, and therefore speed it up, it might still be not as useful as I'd like.

here's the BBC RSS feed for Leeds at the moment:



here's the bit that I'm interested in:



(Temperature: 9°C (48°F), Wind Direction: SW, Wind Speed: 40mph, Relative Humidity: 66%, Pressure: 987mB, rising, Visibility: Good)

Unfortunately, all the juicy bit I'm interested in is all in the same XML tag, so I can't use simpleML to all it's useful yummyness.

This causes a little problem with the words I'm using in my script. For example, "sunny" and "sunny intervals" both contain the word "sunny" so my script will see "sunny intervals" as "sunny". If that makes sense. The script I'm using at the moment is based on a script I used in my last project:


//pulling in feed of weather in stornoway

String[] tokens; //array
int counter;

void setup() {
size(100, 100);


//load file and split up words
String[] lines = loadStrings("http://news.bbc.co.uk/weather/forecast/373/ObservationsRSS.rss");
String allText = join(lines, " ");
tokens = splitTokens(allText, " ,.?!:;[]-");

}

//so it's now pulling in that sentence and splitting it up.

void draw() {
background(255);
fill(0);

String s = tokens[counter];
counter = (counter +1) % tokens.length;
//look at the words one at a time please



//is the word there?

if (s.equals("sunny")) {
println("sunny");
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("white")) {
println("white cloud");
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("grey")) {
println("grey cloud");
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("light")) {
println("light rain");
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("heavy")) {
println("heavy rain");
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("clear")) {
println("clear sky (night)");
noLoop(); //DON'T LOOP IT BAHBEE.

}

}


Now i just need to simpleML it up.

6.5.09

it works... i think...

You may remember my aforementioned buzz buzz, which is a little lilypad arduino circuit with has a light sensor and some vibe boards. I wanted it to vibe when it sees a certain amount of light. After much googling and hair pulling I couldn't figure out what was wrong with my original code.

I decided to come back to it today, and try again. After another couple hours of googling I found this site which had the kind of code i was trying to make. I looked at it and made some changes to my code and now it works!


//if there is light, vibe.

int pins[] = { 9, 10,}; // an array of pin numbers
int num_pins = 6; // the number of pins (i.e. the length of the array)
int ledPin = 13; // LED is connected to digital pin 13
int sensorPin = 0; // light sensor is connected to analog pin 0
int sensorValue; // variable to store the value coming from the sensor


void setup()
{
int i;

for (i = 0; i < num_pins; i++) // the array elements are numbered from 0 to num_pins - 1
pinMode(pins[i], OUTPUT); // set each pin as an output

Serial.begin(9600); //initialize the serial port

}

void loop()
{

int i;

sensorValue = analogRead(sensorPin); // read the value from the sensor
Serial.println(sensorValue); // send that value to the computer


if (sensorValue > 450) {

digitalWrite(pins[i], HIGH);
delay(100);
}
else {
digitalWrite(pins[i], LOW);
delay(100);
}


}


It's a bit tempermental, I think it's more to do with the circuit instead of the light sensor or the code. I'm going to use the data from the light sensor to bring up a feed of where it's sunny now.

5.5.09

i suddenly feel more professional.

I has business cards!



Part of preparation for Futuresonic and hopefully, maybe, possibly takeaway festival down in Londonshire. The pretty little box made me make a happy noise. First person to hassle me at college about it gets a free moo discount voucher. cos I'm nice.



I also feel a bit more loved. Which is always nice.

1.5.09

weather feeds

I've been looking into what weather feeds to use, and found BBC backstage which lets you get access to lots of the BBC's APIs and feeds and such like. It turns out that you can easily get the feeds on the new weather pages anyway!

Here's what an RSS weather feed looks like:



It's actually quite descriptive, there's a description of the weather (sunny intervals, grey clouds or whatever), and temperature, wind direction, wind speed, relative humidity, pressure and visibility. I may not use humidity, pressure or visibility but will definitely use temperature and the wind data.

I've made some notes of the different weather descriptions, and since I'm only looking at the british isles so far it's all relatively similar. I may look into using worldwide data just so there's some variation in what weather the interface reports. If all britain has a really great or pap day in general, the data will be pretty much the same.

Now I just need to come up with some cute things that represent wind and sunny intervals.