Categories
Uncategorized

Processing: HTTP Request

HTTP Request

I’ve been falling behind on Processing Month, but it’s not because I haven’t been hacking away, it’s because I’ve been hitting a lot of walls, not having things work out the way I want them to. I’m trying to not just take other people’s code and go from there, but trying my best to dig through the Processing documentation and reference and figure things out. Sometimes it works… Sometimes it doesn’t.

So that “138” you see above is not very exciting at all. I started working with pulling data from the web into Processing, with the thought that I’ll have a web application output data, that Processing pulls in, and then talks to an Arduino to do… something.

So right now there is a bit of PHP that looks like the following:

<?php echo "138" ?>

And in Processing when I call the println command it outputs this:

HTTP Request

And in draw() after we call the println command, we also call the text command which puts the “138” on the canvas.

I know… it’s fairly unexciting, but it’s a small step. Very small. I have a long way to go to get it working more reliably. Right now, we are reversing the output from the request, and grabbing the first line (index array zero) which should be the last line if we didn’t reverse it. I’m not too clear on array operations yet. (I come from the text processing world of Perl, so there’s a little culture shock in Processing.) Also, if the code outputs anything after the value, it doesn’t work. (I found this out when editing the file in nano, which seems to add an extra line at the end. Urgh)

/*
 * 20110518.pde
 */

import processing.net.*;

Client c;
String data;

void setup() {
  size(800, 600);
  background(0);
  stroke(255);
  c = new Client(this, "rasterweb.net", 80);
  c.write("GET /raster/processing/20110518.php HTTP/1.1\n");
  c.write("Host: rasterweb.net\n\n");
}

void draw() {
  
  if (c.available() > 0) {
    
    data = c.readString();
        
    println(data);
    
    String lines[] = reverse(split(data, "\n"));
    
    textAlign(CENTER);
    textSize(100);
    text(lines[0], width/2, height/2);
        
  }
}

The good news is, since I have been busy with Processing (and if all goes well) I’ll have a new interactive art piece to display at the Milwaukee Makerspace for Bay View Gallery Night.

Categories
Uncategorized

Makey Birthday!

Makey Birthday

Hey folks, it’s a month out from my birthday (June 18th is the day!) and while I typically appreciate the gifts people buy for me, this year I want to make a request, and it goes like this:

1. Make me something!

Yeah, you (together with your own two hands) should make me something. Chance are you’re creative in some way. Maybe you can knit, or draw, or paint, or write a poem or a short story, or compose a song, or take an amazing photo, or maybe you are good with tools, can work with wood, can weld, or cut paper and glue it together, or maybe you make things in the kitchen, like lovely cakes or pizza pies.

If you need some inspiration, check out some of the stuff they highlight on Make, or check out the Flickr photos in the Make or Craft pool. If you really don’t think you can make something yourself, Etsy has things that other people make.

2. Give me money.

Yeah, those are the choices. Either you make me something, or just give me money. (Any amount is fine.) Seriously. Don’t go to the store and buy some mass-produced consumer good. Just make me something, or give me money. How simple is that?

Note #1: In the event you give me money instead of making me something, the money will be used to procure things like food or gasoline.

Note #2: In the event that I get awesome handmade gifts from people, I’ll blog about them, as long as people give me permission to do so.