PComp Final: Programming in Max and Processing

For my Physical Computing final I used Processing to capture and parse sensor data from the tilt switch in the felt ball interface I sewed.  The Xbees sent data into Processing, which were parsed by counting through the data and picking out the relevant sensor information.  Then, I used the MaxLink library to send the data to Max 6.

import com.cycling74.io.*;
import com.cycling74.net.*;
import com.cycling74.util.*;
import maxlink.*;
import com.cycling74.msp.*;
import com.cycling74.max.*;
import com.cycling74.mxjedit.*;
int counter = 0;

import processing.serial.*;
//constructor, references parent object, and Max sketch
MaxLink link = new MaxLink(this, “RecordDemo_D6″);

Serial myPort;

void setup() {
size(50, 50);
// println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
}

void draw() {
}

void serialEvent(Serial myPort) {

int inByte = myPort.read();
if (inByte == 0x7E) {
counter = 0;
println();
}
else {
counter++ ;
}

if (counter == 16) {
println(“THE CRAZY NUMBER IS:” + inByte);
link.output(inByte);
}

print(inByte);
print(” ” );
}

Then, I learned Max and wrote this patch (with the help of Nick Johnson and Michael Rosen) which takes-in and reacts to the sensor data sent from Processing.  This runs the the Max patch, which is a game of Mad Libs played out loud. It prompts you, with a pre-recorded cue to record a part of speech and integrates your response into a pre-recorded story.

P. Comp Final: Fabrication

For my Physical Computing final, I wanted to create an interface that worked for the Mad Libs game. When I was about 8 years old, my friends and I used to play Mad Libs. Everyday we were learning lots of new words and we delighted in the opportunity to use them. Some of my happiest memories from those years took place at sleepovers, so I imagine my Mad Libs game being played among shiny-faced, pajama-clad kids.

The interface for the game is a simple, felt ball containing a breadboard with a tilt sensor (to sense when it’s being thrown from one person to another), an Xbee, a switch, and a 9volt  battery (with 5v regulator).

I used this great pattern to sew the ball out of wool felt. Here are two photos of the unfinished ball, followed by two photos of the finished ball.

Pcomp Final: Xbees sending Sensor Data

Everyone seems to have a strong opinion about the use of Xbees. One professor at ITP told his students never to use them (or any wireless communication), another hailed their reliability (once they’re configured properly.) In my two short weeks working with Xbees I’ve traveled back and forth on that continuum.

First, I spent several long days studying how to configure Xbees (Series 1) and deciding how to use them in my project. My Xbees simply needed to send sensor data from one to another (one Xbee sending, one receiving). I decided not to use an arduino and rather set up two Xbees on two Sparkfun Explorers. (One on a breadboard with a sensor powered by a 9 volt battery (with the appropriate regulator), the other plugged into my computer through a USB to mini-USB connector.)

Configuring the Xbees proved to be a bit of a problem since most resources recommend using X-CTU, a program which doesn’t run on Macs. Finally, I settled on using AT commands on Cool Term.

Here is a sample conversation between me and my Xbee:

Me: +++ (no carriage return)

Xbee: OK

Me: ATID (carriage return)

Xbee:  3332 (This is a default value set by the manufacturer. )

Me: ATID6464 (this is assigning PANID 6464 to the Xbee)

Xbee: OK

Me: ATID (the Xbee is telling you which PANID it has just been assigned)

XBee: 6464

Me: ATWR (saving the values I just gave the Xbee)

Xbee: OK

Command mode (that’s what’s achieved when you press “+++”) times out after 3 seconds so I relied on Tom Igoe’s recommendation to write out all your commands before you get started. Here are my Xbee settings.

 Command  Sending Xbee  Receiving Xbee
 ATID (Pan ID)  6464  6464
 ATMY (My Address)  1234  5678
 ATDL (Destination Address)  5678  1234
 ATD0 (Pin 0)  3  3
 ATD1 (Pin 1)  3  3
 ATD2 (Pin 2)  3  3
 ATD3 (Pin 3)  3  3
 ATD4 (Pin 4)  3  3
 ATD5 (Pin 5)  3  3
 ATIR(Sample Rate)  F9  F9
 ATBD (Data Rate)  3  3
 ATIT (Samples before TX)  5  5
 ATAP (Sets API Mode)  1  1

For more information about the commands and their meanings check out these references:

Download the official The Xbee Manual from this page.

The Unofficial Xbee Cookbook

At some point during this process,  I accidentally reconfigured some of the pins on one of my Xbees. I’m not sure how I did it, but I must have accidentally applied voltage to the Xbee’s reset pin. (So, if you’re a new Xbee user reading this, be careful not to make the same mistake.)

After some doing (and help from Tom) the Xbees finally started communicating. Then, they started sending sensor data. You can see the magic in the video below.

Transistor Lab

I give you: Transistor Lab.

A transistor is a semi-conductor device used to switch (and amplify) electronic signals and power. We used a bi-polar transistor, which has three terminals: base, collector, and emitter. (The other type of transistor is a field-effect transistor the terminals are labeled gate, source, and drain and a voltage at the gate can control a current between source and gain).

In this image, you can see the board set-up (and if this was a video you’d see the motor working.)

H-Bridge Lab

An H Bridge Lab:

After a little bit of work, the I got the motor to change directions a few times, then (as soon as I brought out the video camera) it stopped. So, I added a capacitor. Then it worked again and stopped again. Here’s how the motor looked then, when I thought it wasn’t working.

 

After a bit of work, I realized the motor had been changing direction the whole time, I just couldn’t tell. Once I attached a tape flag, I could easily see the H-Bridge working.

 

PComp Final: Concept/Technology

For my P-comp final project, I want to create a tool for interactive storytelling. I thought it would be interesting to approach interactive storytelling from a character, rather then narrative, perspective. Usually interactive storytelling is about an actor making choices to create an individualized narrative. But with the proper technology, you could instead,  create a single character (or group of characters) who would react against you and the world. The character would make interesting choices, share interesting information, want things from you, give things to you, and a narrative would come out of your interaction with a fully-formed, interactive, (turing-tested) bot.

Creating this is not at my skill level. However, I can provide one good example of a highly-simplified interactive character (embedding on the video was  disabled, so you’ll have to follow this link).

After a lot of daydreaming about how to simplify my dream project,  I settled on using MadLibs as a framework to create an interactive story.

The Plan (Phase 1):

A fabric ball is tossed around by a ground of friends. Sensors inside the ball tell it when it has been caught and thrown. Once the ball is turned on, the first person to catch the ball hears “tell me a noun” the person says a noun of their choice. The word is recorded by a wireless mic onto a recording device in the ball. The ball is thrown and caught again. This time the catcher is prompted to “tell me a verb.” Finally, once a group of words has been recorded, the ball starts recounting a MadLib. Through speakers in the ball, a prerecorded MadLib is played;  gaps in the story are filled in by the player’s recently recorded words.

The Actual Plan (Phase II)

After a little research, I realized that making a totally ball-contained game in two weeks is too much, so here’s the adjusted goal.

A cloth ball with FSR’s (or possibly an accelerometer) is feeding sensor data through one Xbee back to a second Xbee attached to a computer. The first time the ball is caught the computer asks  (probably through prerecorded MP3s in a processing sketch) to say an appropriate word. The computer records the word. (Ideally, the computer could just record whatever sound came immediately after the prompt, but I might need to add a record button to the ball). After all the words have been collected, the computer starts reading back the prerecorded MadLib with the recently recorded words.

That’s the plan. We’ll see how it goes!

P. Comp Midterm: the altar

Robbie Tilton, Christie Leece and I teamed-up to build a Media Controller (for our Physical Computing midterm.) We brainstormed for several days, for several hours straight about God, sacred objects, manipulation, and mind control before settled on a plan. We decided to build a sound system controlled by light. We wanted the sound system to resemble an altar (or a sacred object) and we wanted lighting the candles on the sacred altar to create something resembling a religious experience.

 

Serial Output: Graphing a Sensor

Here is a video of my graph of serial output.  As you can see the values bottom-out really fast.

When imagining exactly what was happening during this lab, it helped to know that all information was transferred from the Arduino to my computer in bytes (little 8 bit packets of data). When working with the data in either C or Java, we had to make sure to divide the values by 4 because the 8-bit data had become 10-bit data again (10-bit was its original form) and both programming languages work with 8-bit data better.

Also, I’m really excited to finally know what ASCII characters are. I’ve been running up against them my whole life, and it finally isn’t gibberish. Thank God!

Public Interactive Technology

    The piece of public interactive technology I chose is a series of doors into a nearby apartment building. The first door is automatic, the second door can only be opened by the doorman. But, both doors look identical. During the time I spend observing people walking in and out of the doors, I saw several  delivery men walk confidently through the first door only to stamp around on the floor in front of the second door, looking for an FSR or motion sensor to open it.
    Both doors are completely glass and slide on a track, so there is no visible way of manually opening them. It must create a feeling of hopelessness when you are trapped between the inner and outer doors, like a frog in a sparse tank. It brings up what Norman said in “The Design of Everyday Things” about the responsibility of designers to make the operation of things clear. Their is no way to figure out how to open the inner door by looking at it.
    But, residents of the apartment building rarely have to think about that. They breeze through the doors in seconds. When the doorman is there, his response time allows them to feel as if the inner and outer doors are both automatic. When he is not there, they simply wave a card in front of a sensor and the inner door opens. Although, It’s clear that the doormen are almost always at the door because when the tenants were forced to find their cards, they often hunted for it for quite some time. (I assume that if using their card were a regular thing, more people would be prepared with it in hand.) I was also reminded of Norman’s reading when imagining people trying to get inside the building in an emergency. No one threw themselves up against the door in an frenzy when I was watching, but one women on her smartphone almost walked into the inner door, when the doorman was absent.
   The longest interaction with the door took just under a minute, which mostly involved a woman hunting through a large bag for her entry card. She finally walked through the inner door as it slid open in front of her, heaving her bag  further onto her shoulder as she did so.

Tone Lab

Ladies and Gentleman, I give you: tone lab.

 

During the second part of the lab I had a question:

At first, when I looked at the example in the syllabus, I thought the “thisNote” variable referred to the “notes” and/or “duration” array. I was confused as to why we would use the same variable to refer to different arrays. Then, I realized, “thisNote” was just a counting variable. It is responsible for moving us from one note/duration to another in single increments.
_______________

#include “pitches.h”

int notes[]={NOTE_C4, NOTE_G3, NOTE_G3, NOTE_GS3, NOTE_G3, 0, NOTE_B3, NOTE_C4};
int duration[]={4,8,8,4,4,4,4,4};

void setup() {
}

void loop() {
for (int thisNote=0; thisNote<8; thisNote++) {
int noteDuration=1000/duration[thisNote];
tone(8,notes[thisNote], noteDuration);
delay(noteDuration +30);
}
}
_____________