Archive for the 'Programming' Category

Flexor Glove

So it’s done. I successfully wired up a glove with two sensors and connected them via Arduino and Processing to my laptop. When the fingers curl, the graphics draw to a screen. I covered a lot of ground in this project, and I surprised myself that I actually made this work. The one aspect that surprised me was understanding gesture, and how the natural movements of the body must be considered to make a good experience. In fact, at the last minute, I changed the interactivity between the fingers, because I found it easier to control the tweet drawings with my index finger than with my pinkie.

This is the value of a prototype: to be able to test something early and often, and then modify based on use and interaction. All in all, this has been great fun!

progress!

I spent most of today working on pulling the sensor values into an array so I can make something draw when moving each finger. I finally got it! I used the input code from the Virtual Color Mixer code on the Arduino site, but I also had to keep the syntax from the original Flex Sensor code as well. I kept trying to just modify the code, but it wouldn’t work, so I had to strip everything down to a basic prototype to get it working. And I learned something really small, but powerful. Check this:

Serial.print (analogRead(index));
Serial.print (“,”);
Serial.println (analogRead(pinkie));

Note that the last line has “println” not just “print”. That syntax will make the next line start on a new line, breaking the stream of numbers. This is important, as this string of characters will be pulled into this code to be split and divided into the values for the index finger and the pinkie finger movements.

void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil(‘\n’);
println(inString);
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);

// convert to an int and split into array:
float[] curls = float(split(inString, “,”));

if (curls.length >= 2) {
indexValue = map(curls[0], 0, 900, 0, 255);
pinkieValue = map(curls[1], 0, 90, 0, 255);
}

If the incoming string does not have the right syntax, it just won’t work. Now that I have a rough working prototype, now I have to paste in the dots & lines and the Twitter API to get the visuals as I want them. Good thing I have some chocolate.

gesture appropriate

I’m trying to figure out which finger to attach the second flexor sensor. I had originally thought the flexors should go on the index and middle fingers, as they seem to be the most controllable fingers (no bad jokes here, ok?). But as I have been playing with my glove prototype, I realize that it’s pretty hard to move either of these fingers independently of each other. Try it: raise your hand, and then curl your index finger. The middle finger curls with it! This is because of the extensor tendons, which a quick search through Google has unearthed. It seems the thumb also has the same effect, so I am going to put the second sensor on the pinkie finger, as it seems to have the least connection to the movement of the index finger. And I think that will be kind of funny, to pull in tweets by culring your little finger. Hee hee.

I have to admit, I am quite delighted how quickly I’ve become connected back to the mechanics of the body by experimenting with wearable technology. Understanding natural gestures, the limitations of movement, ergonomics, it’s all quite intimate knowledge. It’s all just beginning to click…

 

raining yet?

I’m working on the graphics for my projection, playing with lines and circles to create rain-like visuals. The lines and circles build as you crunch your fingers, the interaction is connected to the flexible sensor. As the curve increases in the sensor, the resistance measurement is sent through the analog pin on the Arduino board. I am using simple draw functions right now, but I am aiming to clean up the code to make this effect more random and recursive. Here’s the code I am using to draw the lines and circles:

if (inByte > 70) {
// draw the line:
stroke(225);
line(xPos, -height, xPos + 10, height – inByte);
stroke(225);
line(xPos + 10, -height, xPos + 40, height – inByte);
stroke(225);
line(xPos + 20, -height, xPos + 100, height – inByte);
stroke(225);
line(xPos, -height, xPos + 200, height – inByte);
stroke(225);
line(xPos + 50, -height, xPos + 250, height – inByte);
stroke(225);
line(xPos + 80, -height, xPos + 280, height – inByte);
stroke(225);
line(xPos, -height, xPos + 300, height – inByte);
stroke(225);
line(xPos + 170, -height, xPos + 500, height – inByte);
stroke(225);
line(xPos + 210, -height, xPos + 600, height – inByte);
cs = new CircleGlyph[10];
for (int i = 0; i < cs.length; i = i + 1) {
cs[i] = new CircleGlyph();
cs[i].paint();
}

… and the circle code is sitting in a class…

void paint() {
//action could be called anything, make it meaningful
fill(240, 240, 240, random(240));
noStroke();

ellipse (x, y, 10 + s, 10 + s);
}
}

I know this can be refined, but I’m really more concerned with the aesthetics at the moment. I want to pull a colour palette from this image of a storm I took in Thailand years ago. Carrying on…

 

Glove prototype begins

I have successfully attached the Flexor to a glove to continue my glove prototype. I bought some black silky gloves at a dance store. Strangely, choosing the color was a challenge: black, red or white? I ended up choosing black as I felt it had less significance than red or white. I pierced a small hole into the end of the flexor plastic and sewed it directly to the glove, then just looped the thread around flexor and tacked it to the glove. I want it to be able to move around a bit when the hand was moving. I hope the glove will stretch to fit any hand, but at this point, it makes an adequate prototype.

I attached the glove to the Arduino and then ran my Processing program. It works really well! So now I must move to creating graphics and pulling the Weather API and Twitter search results into a Processing sketch. I;m hoping it won’t be too mind bending. I also really want to strive to make the graphics as analog as possible, perhaps by creating some recursive movement, just to add more randomness. Onward and forward.

Flexor!

Tonight was hella fun. I got my flexible resistors in the mail, and I was super excited to start playing with them. I followed the instructions from the Sparkfun Electronics website on how to hook up a simple circuit. First i had to solder some wires to the resistor. Then I had to connect the resistor to the Arduino with another resistor. It was overall pretty easy, but I still need a lot of practice reading electronic schematics. Then the code. Basically, I took the code from the Sparkfun tutorial and mixed it with the Graph code from the Arduino site. A big thank you to the people who write this code and share it online, I would get nowhere without it! Anyways check out my l’il video of the whole experiment.

 

Programming Interaction

So I’m working on a prototype for programming class. We are required to do the following:

  • integrate API data, such as weather stats,
  • wire up a physical control for interaction, and
  • visualize said interactions on a projection.

I had started thinking I would pull sunrise and sunset time and make an alternative clock that would give ayurvedic phases of the day. But I wasn’t feeling very inspired by the interaction element. Yes, it will be challenging to wire up a key pad and have the screen change with button clicks, but how compelling is that for the user? I want to create a fun experience that may evoke some wonder. You know, something that intrigues ME. Button clicks weren’t cutting it.

So I moved instead to something that I want to play around with, and that is wearable technology and those crazy flexible resistors. Yes, I am going to make my own interactive gloves that send signals when you bend your fingers. I wrote a poem a long time ago called The Storm, and I am going to call this piece Make It Rain. The idea is that people will be able to make data rain on the screen by moving their fingers. I am hoping it will have an uncontrolled randomness, and be beautiful at the same time. I’d like to weave still images, some web data and perhaps sound together into the experience. I saw some beautifully evocative pieces at the de Young today that inspired my visual thinking, and I hope I can reflect some of that into the execution. Wish me luck!