We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Internet to LED beginner (Read 2595 times)
Internet to LED beginner
Aug 27th, 2005, 7:20pm
 
Hi
I have no prior knowledge of programming, so my progress is slow, and any guidence would be much appreciated, this is my case: (and where I am stuck)
The project is about making a public display of pollution levels in the city

On the internet there is a file that is updatet 4-6 times a day, it displays the date and then a list of comma separated numbers like this:
20050825 (YYYYMMDD)
4,2 (4 is thursday, 2 is level of pollution on a scale from 1-5)

In this case I want 2 LEDs to be turned on and then check say every five minutes for updates if levels have changed.

I found the "Http client" Example and put in the URL and it prints the file OK (with info on the server on top)

now how do i grap the right number and pass it on to the serialport?
(the route I hope to finally take is via serialport to processor to LED.)

If someone knows of a similar example online with the code it would also be great

thanks in advance

niro
Re: Internet to LED beginner
Reply #1 - Aug 29th, 2005, 5:13pm
 
hi
thought I would provide more specific info,

I made a temporary website for the project here:
http://org-urb.dk/luft/uk/

Below is the code I am having trouble with, both scripts seem to work individually, but I cant make them play together, it is a question of sorting and sending the right information i think


Code:
 

/ http client
// by Tom Igoe

// Starts a network client that connects to a server on port 80,
// sends an HTTP 1.1 GET request, and prints the results.

// created March 18, 2005

import processing.net.*;

Client client;

void setup()
{
size(200, 200);
noStroke();
// Open a TCP socket to the host:
client = new Client(this, "www2.dmu.dk", 80);

// Print the IP address of the host:
println(client.ip());

// Send the HTTP GET request:
client.write("GET /atmosphericenvironment/thor/mjk/melding.inc
HTTP/1.1\n"); //this points to the file on the internet with the data
client.write("HOST: www2.dmu.dk\n\n");
}

void draw()
{
background(0);
// Print the results of the GET:
while (client.available() > 0) { //changed if to while from original code
int inByte = client.read();
print((char)inByte);
}
}
//this prints the file that I am interested in hurray


/* Example of what is printed:
this is an example of what the http client writes
195.41.77.12
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
X-Powered-By: ASP.NET
Date: Mon, 29 Aug 2005 08:15:03 GMT
Content-Type: application/octet-stream
Accept-Ranges: bytes
Last-Modified: Mon, 29 Aug 2005 05:13:27 GMT
ETag: "c3fc566358acc51:96b"
Content-Length: 25

20050829
1,2
2,2
3,3

*/


/*
this is what I think follows, the code below works alone but not together with the above
what i want to do is send data to the serialport
I dont know a way to point to the right number yet, I
am interested in the line: 1,2 and then the second number, in this case 2

*/


/* code is commented out for now as it doesnt work together

import processing.serial.*;

// the serial port:
Serial port;

// variable to hold values:
int thisByte = -1;

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

//the port is set to 2 and baudrate set to 2400
port = new Serial(this, Serial.list()[2], 2400);

// Send data to serial port, trough variable inByte, -could be this
command is also wrong:
port.write(thisByte);
}
*/



Page Index Toggle Pages: 1