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.