Hi, I'm Jim McMahon, and this is my documentation for my The Epiphany Machine physical computing final project. I've broken down this pleasant foray into mechanical madness according to six (6) sections. They are as follows:
1. Concept drawing and controller key
2. Content and general project explanation/description
3. Pseudo-code and general plan-of-attack for completing project
4. Construction and building process pictures
5. Troubleshooting log
6. Conclusion/Sources Cited
Before I begin to lay out for you a tale of tortuous, tenacious technicality, I must inundate you with a brief explanation as to my motives behind the project, and why I wish to see this particular choice through to completion. I graduated from Ohio University with a major in Interactive Multimedia and a minor in English, and while I get plenty of chances to put my multimedia skills to practical use in this program, the constant concocting of correct coding in my classes leaves me yearning for some good 'ol fashioned English and creative writing.
The idea for this came as I was meeting with my physical computing instructor, and attempting to figure out what to do for my final project. As I had no ideas, she simply asked what I liked, and writing being one of them, I decided to see what could come about from the suggestion. My instructor and I chatted about a possible word-changing controller, and I decided to run with the idea as far as my embarrassingly small, bow-legged PComp legs could carry it.
As such, displayed for your viewing pleasure below is an image of the general concept of which I was thinking. Colors in the final incarnation may vary (see also: "I'm using wood, dammit").
1. Concept Drawing and Controller Key

2. Content and General Project Explanation/Description
The main idea behind this thing is to generate, via hands-on manipulation, a creative writing exercise on-the-fly. One exercise I did in college included writing random favorite words from all members of the class onto the blackboard, and subsequently giving the students free reign to write whatever they liked, as long as they forced those words somewhere into their story. Different results followed, from minimalist poetry using only the suggested words and few others, to long, epic (if not bloated) narratives that had no chance of being completed in the 50 minutes of class time we were alotted.
The idea here is a similar one; I'm aiming to allow for options of building sentences input by input, or perhaps having static sentence structure and allowing for variable components of said sentence, much like a mad lib. This will work by serial communication between the Arduino Microcontroller, the Arduino code environment, and the Processing IDE, which will display the results of all that future twisting, turning and pushing in the form of sentences and phrases, or whatever form the user wishes from their choices.
A sample list of words (chosen by me) will respond when variable data is received. For example,
Nouns - brain, turtle, ninja
Verbs - caroom, vomit, fall
Adjectives - contagious, frappish, monomaniacal
Etc...
The construction of unexpected sentences has always helped me hurdle creative dumbfoundery, and a tactile approach will hopefully get the brain thinking in a slightly different way. Ideally this will lead to literary trysts into an imaginitive stratosphere, screaming inky divinity from the end of a ballpoint pen, and enable those modern progeny of Atlas to cast off thy hunched 'n bunched shoulders the soul-crushing weight of writer's block into the briny sea of worthless bombastic bullcrap metaphors.
3. Pseudo-Code and General Plan-of-Attack for Completing Project
I intend to base my initial progress off the Lab 5 - Serial Communication lecture and notes, and to start by making sure all software is correctly installed, as previously I had been missing the drivers in Arduino when I downloaded to my computer.
After this will be a confirmation check to examine if all my equipment is ready by completing the first couple labs, which also will serve to refresh my memory on certain basics.
I will then start the serial communication lab, and attempt to understand how the code works so that I may manipulate certain parameters and areas of the Processing code to better visually illustrate my concept idea.
I will need to revisit how to most effectively use string arrays for my project, so that the words can be displayed on the screen instead of just at "println." I will have to figure out how to map certain physical actions (such as button pushing or pot twisting) to actions in Processing, and to think about how to possibly design such an interface for effective display and usability.
I will then build the prototype for the project, which will definately not look even remotely close to the concept idea, but will instead be an amalgamation of wires, wood, and metal pieces.
Finally, user-testing and cross-platform compatibility will commence, and I hopefully will have the project finished to an acceptable state.
Interface (Processing) pseudo-code
Allow user (for now) to construct his/her own sentence on-the-fly. Basically, whichever potentiometer or pushbutton the user tweaks or presses becomes the next word in the sentence, and while tweaking or pressing the buttons, the screen will show the user cycling through words in a pre-determined (by me) list in real-time, and those words each will be mapped according to a numerical equivalency for accurate mapping.
If any other pot other than the one currently active is activated, move behind last word/string (maybe 10 px from width) and begin cycling through list of verbs, nouns, adjectives, or whatever the user chooses to continue tweaking.
If button is pressed, cycle once through list next word/string. If string is "(this)," change all words/values/strings to matching parameters of the selected.
Design interface should be simple and not very visually cluttered or prominent in any way so as to be distracting for user. Black background will be erasable, by assigning the background command once in setup and once in a key, mouse or serial event. Text will be light gray (#CCCCCC) to mute effect of stark black/white color contrast to eyes constantly fixed on it, and to disallow the "I'm Burning This Damn Text Into My Retinas As Afterimages! The Pain! I Can't Stop Looking At the Words Green Eggs and Ham! Oh Why Did I Peruse Dr. Seuss While Taking a Bathroom Deuce and Then Start Typing Green Eggs and Ham-Related Poetry To My Laptop?!" Effect.
Include "return"-type button which skips to next line and starts at leftmost position on line, which allows for greater freedom with experimentation (e.g. poetry), and enforces left-alignment, which is the common form. Ideally, this project would eventually progress to the point where I could create the option for tabs or spaces or total object alignment, for those who prefer their text centered.
In future, perhaps map A, B, C, etc. on the controller buttons to increase gameplay dynamic, and include suggested "templates" for experimentation with guaranteed somewhat grammatically-feasible results; like in video game codebooks, for example:
"EABDCA," where:
Declarative Article = E, Noun = A, Verb = B, Pronoun = D, Adjective = C, and Noun = A, which could conceivably, as an example, be interpreted on the screen as:
the cheeseburger kicked my voluptuous donkey
*Still curious what effect introducing color to the controller will bring on information-retention methods...
Thoughts on Concious Decisions
The interface for this project's interactivity is relatively simple for many concious decisions, described below:
1. Black background always seems (to me) less intimidating than white space; perhaps because there's an unconcious association to the memory of writer's block or something. Also, it seems more conducive to daydreams and fantasies, which hopefully will speed up "writing epiphany" process.
2. Gray text won't burn itself into your retinas like white, and thus allow for a longer endurance period for your eye to focus correctly on screen.
3. Minimalistic design theme between black background and gray text that seems to work, despite being a bit (purposefully) dull.
4. No punctuation eliminates the distracting tendencies to incessantly tweak grammar, which distracts users from concentrating on the words themselves and their properties. Grammatical structuring should occur later as a secondary result to what they created on the screen with the controller.
5. Limited choice of words prevents the time-consuming, train-of-thought-derailing habit of searching endlessly for the Right Word to perfectly express a feeling or thought. In itself, that's a great thing, but not while in the middle of completing content in a sentence and attempting to awash yourself in your own stream-of-conciousness thinking.
6. Using a tactile approach will hopefully perform a better job of:
a) forcing the user to interpret phrases, sentences, meaning and punctuation,
b) allowing writers of multiple skill sets a method to drop the creative writer's block and rekindle the creative fire, which might seep back into their intended work,
c) engaging the more mechanically-inclined and hands-on learners to allow them to better understand and perhaps appreciate the craft and spark a curiousity to practice themselves,
d) teaching those learning the language, be it young children, handicapped, or international people some basics of communication in English,
e) allowing more concrete mental associations between controller action and screen (basic elements of gameplay),
f) encouraging careful attention to sentence structure, especially if I use "difficulty" choices of words ranging from "common usage" to "hard/unique/complicated/jargon"-type scales.
Below are pics of interface design with the same text content:
[ignoring the RETURN-key option and interacting regularly]

[using RETURN-key option for structural experimentation; in this case, poetry]

4. Construction and Building Process Pictures
Here are some iSight pictures I saved from Processing allowing a visual record of what I've been attempting so far...
These first three pictures are of the layout of my breadboard, currently configured for and awaiting completion of Lab 5 before getting anywhere else.



Here are pics of my tools and tacklebox, with freshly soldered potentiometers and switches all ready to go and awaiting my command.


Here is the computer screen, feebly (in this light) showing my Processing code and Arduino and Terminal windows in the background.

Finally, a true hallmark of any stressful, hair follicle-endangering project:

That's right, Chinese take-out from the 'hood, along with a copy of Firefly to allow confident reassertion of my nerdliness.
These are updated pics of the Epiphany Machine breadboard configuration and layout, while I was trying to figure out what the hell was wrong with the code (again).





Hopefully, I can re-configure this mess of wires for a better looking and "functioning" prototype.
Here is a better looking series of photos about the prototype of the project, though I miscalculated how to include the potentiometer with the buttons, and I just didn't have time to do the necessary arduous and time-consuming task of calculations and measurements that inevitably come from such a "simple" process as poking holes in the foam-core and expecting everything to fall into place (I probably should have laid out a detailed battle plan before engaging in this, but I was too preoccupied trying to figure out why in the name of all that is Holy my code still won't work). This is the final looksie.








Troubleshooting Log
This is the section of my documentation whereby I cry and whine and bitch and moan about why in the hell various parts of my project aren't working. At this point, it's the reason why I'm not further along and anywhere close to where I want to be.
- Had problems with Analog In/Out lab; apparantly PCs are configured wrong in their port setup or whatever. Carlyn helped; looking forward to working on a computer that doesn't annoy the crap out of me, or suck an unnecessary 4 hours out of my life trying to figure out what went wrong.
- Had problems with Serial Communication Lab 5, in the form of not being able to get the Terminal to communicate the way it's supposed to; was advised in class to double-check and make sure I installed correct drivers on my computer. Did so and problem ceased.
- Had problems attempting to figure out what was broadly wrong with Serial Communication Lab 5, as I still cannot get it to work. Sample of e-mail to instructor:
"I know that my breadboard is
wired correctly, because I'm getting values for my two pots and my one
pushbutton in the Terminal, each of which change accordingly when I
twist either of the two pots or push the button. In essence, the
Arduino code seems to be working fine.
The Processing example code, therefore, is the problem. It doesn't work
when I straight copy-and-paste it into the program. It doesn't work
when I change the "port = new Serial(this, Serial.list()[0], 9600);"
command by replacing the "[0]" after "Serial.list()" with any other
number, although 0 and 1 will make the screen black, and 2 and 3 result in:
RXTX uucp_lock() /var/lock/LK.001.009.002 is there
gnu.io.PortInUseException: Unknown Application
java.lang.RuntimeException: Error inside Serial.()
at processing.serial.Serial.errorMessage(Serial.java:575)
at processing.serial.Serial.(Serial.java:148)
at processing.serial.Serial.(Serial.java:102)
at Temporary_7088_1670.setup(Temporary_7088_1670.java:26)
at processing.core.PApplet.handleDisplay(PApplet.java:1237)
at processing.core.PGraphics.requestDisplay(PGraphics.java:568)
at processing.core.PApplet.run(PApplet.java:1406)
at java.lang.Thread.run(Thread.java:613)
These are the listings of my ports:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
/dev/tty.modem
/dev/cu.modem
/dev/tty.usbserial-A1000ewV
/dev/cu.usbserial-A1000ewV
Is the port in use by some other program and blocking what I'm trying to
send? This has happened while I had the Terminal up and running, as
well as when the Terminal hadn't been activated after restart. My port
should correspond to number 2, according to the logic of the directions,
but all that happens is a blank applet, not doing or showing anything
but gray. I can force the ball to appear by not linking its color to a
variable, but it won't move at all, despite my sending a capital A to
begin serial commincation; I typed capital A in the terminal, as well as
when the applet is active."
Later, I was able to considerably narrow the problem with help from my housemate, who is a programmer. An example of a revised e-mail:
"we were able to narrow
the problem down to a single line of code in the "setup" area:
port = new Serial(this, Serial.list()[2], 9600);
Most of that line seems to work except the "this" parent Papplet
parameter. The complete code is below (with a bunch of "println"
commands for extra debugging testing), and the result is displayed in
the error log area at the bottom of the Processing window. The applet
generated was of a blank screen, mainly because the program encountered
the error before "draw." Throughout this entire process, Arduino was
running the required code, and the Terminal program was open and running.
//Processing Code
import processing.serial.*;
int bgcolor; // Background color
int fgcolor; // Fill color
Serial port; // The serial port
int[] serialInArray = new int[3]; // Where we'll put what we receive
int serialCount = 0; // A count of how many bytes we receive
int xpos, ypos; // Starting position of the ball
boolean firstContact = false; // Whether we've heard from the
microcontroller
void setup() {
size(256, 256); // Stage size
noStroke(); // No border on the next thing drawn
// Set the starting position of the ball (middle of the stage)
xpos = width/2;
ypos = height/2;
// Print a list of the serial ports, for debugging purposes:
println(Serial.list());
println("port 2 = " + Serial.list()[2]);
println("this=" + this);
// I know that the first port in the serial list on my mac
// is always my Keyspan adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
port = new Serial(this, Serial.list()[2], 9600);
println("1");
port.write(65); // Send a capital A to start the microcontroller
sending
println("2");
}
void draw() {
background(bgcolor);
fill(fgcolor);
// Draw the shape
ellipse(xpos, ypos, 20, 20);
println("xpos=" + xpos + ", ypos=" + ypos);
// If no serial data has beAeen received, send again until we get some.
// (in case you tend to start Processing before you start your
// external device):
if (firstContact == false) {
delay(300);
port.write(65);
}
}
void serialEvent(Serial port) {
println("se: port=" + port);
// if this is the first byte received,
// take note of that fact:
if (firstContact == false) {
firstContact = true;
}
// Add the latest byte from the serial port to array:
serialInArray[serialCount] = port.read();
serialCount++;
// If we have 3 bytes:
if (serialCount > 2 ) {
xpos = serialInArray[0];
ypos = serialInArray[1];
fgcolor = serialInArray[2];
// print the values (for debugging purposes only):
println(xpos + "\t" + ypos + "\t" + fgcolor);
// Send a capital A to request new sensor readings:
port.write(65);
// Reset serialCount:
serialCount = 0;
}
}
//This is what I get in the bottom window after hitting the Play button:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
/dev/tty.modem
/dev/cu.modem
/dev/tty.usbserial-A1000ewV
/dev/cu.usbserial-A1000ewV
port 2 = /dev/tty.usbserial-A1000ewV
this=Temporary_1274_4015[panel0,0,22,256x256,layout=java.awt.FlowLayout]//Is
there something here that's causing the problem? -Jim
RXTX Warning: Removing stale lock file. /var/lock/LK.001.009.002
gnu.io.PortInUseException: Unknown Application
java.lang.RuntimeException: Error inside Serial.()
at processing.serial.Serial.errorMessage(Serial.java:575)
at processing.serial.Serial.(Serial.java:148)
at processing.serial.Serial.(Serial.java:102)
at Temporary_1274_4015.setup(Temporary_1274_4015.java:28)
at processing.core.PApplet.handleDisplay(PApplet.java:1237)
at processing.core.PGraphics.requestDisplay(PGraphics.java:568)
at processing.core.PApplet.run(PApplet.java:1406)
at java.lang.Thread.run(Thread.java:613)
My housemate kept asking if there was a source code to look at, which
had something to do with serial initialization. I'm not exactly sure
what he's talking about, but maybe that can explain the problem I'm
having a bit better. In essence, my pot twisting and button pushing is
not being picked up by Processing, and that very basic condition needs
to work before I can go any further."
And this is where I am irredeemingly, irrefutably, incomprehensibly stuck the f*ck in a mucky rut. I can't get anywhere from here, as my basic condition has not been met, despite all attempts to remedy the situation. I'm despondent, and reeling still from the heinous blast of shattered self-confidence and melancholic mourning for a victory that should have been...
Nevermind...
Apparantly the problem was my brain operating on different logic than the directions assumed. I literally did almost everything under the sun to get that damn code to work, and I found out all I had to do was quit Arduino and the Mac Terminal program and just run the Processing code. I had thought it fundamentally important to have at least two programs talking to each other during serial communication, which is technically right, BUT those two programs must be the Arduino Microcontroller itself and some kind of IDE (or Terminal) open and running the required serial recognizable code. Having two programs attempting to control the port is impossible and so I needed to actually kill the other programs. This seems such a basic mistake, but to be perfectly honest, I worked my ass off to figure this out (insert vague, caveman-like grunting sound as emphasis).
12.10.06
After my (ahem) epiphany(!) concerning the need to quit Arduino before uploading code, I ran into another wall, which was basically programming my code in an efficient and generally operable manner with the added features to my breadboard configuration. I met with my instructor, and she rewrote the lab to work with serial communication and send what I needed to get my Processing code to begin working. Unfortunately...
PROBLEM: The Processing code does not work correctly. I came to this conclusion after testing the Arduino code and finding that it sent the correct values for the correct things, as shown below:

In the above example, the first three numbers are the potentiometer values, and the 6 digits that appear after each correspond to one pushbutton (which is wired to the breadboard). The Arduino code works fine. After I upload this and test it, I then will stop the code, quit Arduino, and start up Processing, and to choose the PDE file from "open sketchbook" menu. I run the code, and nothing happens except:

All it does is show a black background and print the serial port list. Nothing else, even when called to println, happens. What you saw is what I got.
As a result of my ineptitude to get this code to work, I've tried all manner of troubleshooting the code, but the problem is that I can't identify specifically what is wrong enough to know what to do or where to look to fix it. I know where the problem resides:
void serialEvent(Serial port) {
// if this is the first byte received,
// take note of that fact:
if (firstContact == false) {
firstContact = true;
}
// Add the latest byte from the serial port to array:
serialInArray[serialCount] = port.read();
serialCount++;
// If we have 7 bytes:
if (serialCount > 6 ) {
int eraVar = serialInArray[0];
println("EraVar:" + eraVar);
for (int i = 1; i < 7; i ++) {
int num = serialInArray[i];
// print the values (for debugging purposes only):
//println(xpos + "\t" + ypos + "\t" + fgcolor);
switch(num) {
case 0:
println("Switch" + i + "Is not pressed"); // Does not execute
break;
case 1:
println("Noun"); // Prints "Noun"
break;
case 2:
println("Verb"); // Prints "Verb"
break;
case 3:
println("Adjective"); // Prints "Adjective"
break;
case 4:
println("Adverb"); // Prints "Adverb"
break;
case 5:
println("Reset"); // Prints "Reset"
break;
case 6:
println("LineBreak"); // Prints "LineBreak"
break;
}
}
}
// Send a capital A to request new sensor readings:
port.write(65);
// Reset serialCount:
serialCount = 0;
}
The serialEvent() seems to be the culprit of what's wrong, but I have no idea where at in the code to figure it out. I've tried moving around placements of nested statements, like moving the " for (int i = 1; i < 7; i ++) {"-command and everything in it to the same level as the preceding "if (serialCount > 6 ) {"-command, which allows the "eraVar" to print repeatedly, and "println("Switch" + i + "Is not pressed");"-command to print as well. The problem with that, though, is my computer freezes everytime I do it (even the CAPS lock light won't go out if it's on), and I have to do a hard restart every time, which I'm loathe to do.
I guess what I need to know is if there's a way to slow down serialEvent() from printing so fast so I can experiment without a crashing computer, and in general to get interaction between the button-pushing and potentiometer twisting. There's a value, "48," which seems to be the default value of the potentiometer that's being transmitted or interpreted when I test for such, which also is a strange problem...Processing doesn't seem to be reading the correct values being sent. What the f*ck is going on?
6. Conclusion/Sources Cited
My conclusion thus far is a somewhat limited one, as I was only able to progress so far without the use of actual serial communication between Processing and Arduino, the point of my project. I believe that given enough time, I could make an interesting little device that might help some people break out of a momentary creative block, which was really all I was hoping for, though my eternal impatience with PComp would probably win out over my desire to see the project through to its fullest. If I've learned anything from this Great Experiment, it would have to be a markedly improved ability to debug Processing, as well as get a sense of what is "probably" going wrong in any given application I tend to run. I've learned a bit about serial, too; pretty much everything I need to know up until the actual communication-with-Processing part.
What follows are my sources and those whom I cite throughout my work...
Notes:
- Physical Computing, ITP 2006 Fall semester, instructed by Carlyn Maw
- Physical Computing, by Dan O'Sullivan and Tom Igoe, Thompson Course Technology, MA. 2004.
- Classmates' online notes and journals, at:
"http://itp.nyu.edu/~cm1002/Fall2006/pComp/index.php?n=Notes.Class" and
"http://itp.nyu.edu/~cm1002/Fall2006/pComp/index.php?n=Notes.Journals"
- Various pages of ITP's Physical Computing web directory:
"http://itp.nyu.edu/physcomp/"
- Arduino and Processing reference libraries, environments, and tools:
"http://www.arduino.cc/" - Arduino homepage
"http://www.processing.org/" - Processing homepage
Consulting/Extra Help:
- Carlyn Maw, my Physical Computing Instructor
- My housemates Ron and Kyle (don't know their last names)
- Felipe Ribeiro, and various other student and teacher input from ITP
- Anyone or anything I forgot (always inevitable)
Thank you for visiting my documentation page. Perhaps someday this device will appear, as if out of the blue, on a newspaper's front page (or page 8) declaring a temporary cure for creative ills, as I am left standing alone in a puddle of questionable liquid in a Subway car, riding off to who knows where and briefly reading over the shoulder of some poor soul who wants nothing but an assurance that I won't rob him this night, if he'll only just let me read a little further the realization of a rough blueprint from long ago.
Thanks again for all those who helped me throughout this semester. I cannot describe how much I appreciate your patience and support.
James (Jim) Franklin McMahon VIII - ITP Fall '06, Class of 2008.