News for the ‘PComp’ Category

Construction of SwingFWD

Posted: December 7th, 2009
Categories: ICM, PComp
Tags: ,
Comments: No Comments.

Final Project Concept

swingfinal

I found inspiration for my final project from an installation piece created by Su-Mei Tse.  I want to build a swing the user can sit in, and as they swing they control video being projected on the wall in front, to the side, and above them. For me the swing symbolizes childhood.  I want the user to feel as if they are scrubbing their own memory as they are physically swinging, inducing a nostalgic experience.

I will be attaching an accelerometer to the bottom of the swing seat.  Using the call and response method, I will send serial data from arduino over to processing. As the user swings the processing sketch will scrub through the video I have taken.   I will also need to work with an Xbee to make the project wireless.

First steps:  Mapping the accelerometer (using Tom Igoe’s code)

mapping an accelerometer from Susan Ngo on Vimeo.

Posted: November 24th, 2009
Categories: ICM, PComp
Tags: ,
Comments: No Comments.

Inspiration for Final P-Comp Project

Swing by Su-Mei Tse.

Swing, 2007 from on Vimeo.

Posted: November 17th, 2009
Categories: PComp
Tags:
Comments: No Comments.

Sensor Observation

I moved from Boston to New York in August.  The Massachusetts Bay Transit system train lines are (inefficiently) designed to move towards a radial point, making Boston buses the fastest way to get around.   On a bus in Boston, if you want the backdoor of a bus to open you shout “rear door” as loudly as possible until the bus driver begrudgingly opens it.  During the P-comp class, Noah mentioned how the yellow tape on the backdoor of New York buses opens the backdoor.  The idea of being able to open the backdoor of a bus myself by simply pressing on tape sadly amazed me.

I ride the 38 bus every day, and I have never used the yellow tape and have also never noticed anyone else using it. Usually I see people battling with the backdoor and forcing it open followed by people holding the backdoor for each other for fear that the door would coming swinging closed on the person behind them.  I decided to spend a couple of bus rides seeing people interact with the magical yellow tape. On my first observation, the particular bus I was on only had a torn away remnant of the instructional sign for opening the backdoor.  This might explain why not a single person on my commute used the yellow tape to open the door. When it was time for me to get off the bus, I shyly pushed the tape with no result. The person next to me jumped in and pushed the yellow tape even harder and finally the doors opened.  On my second observation, the instructions appeared right above the tape and about half the people on the bus used it while the other half did not.  When the bus reached my stop, this time i more confidently pushed the yellow tape and after a moment’s pause the door without force swung open.

Posted: November 17th, 2009
Categories: PComp
Tags:
Comments: No Comments.

PComp Midterm: Zen Grass

Untitled from Susan Ngo on Vimeo.

The Project:

Zen Grass was a project I collaborated on with Jenine Durland and Christine Nguyen. The concept of zen grass was to create a synaesthetic experience, combining touch with sound and smell. The main goal was to encourage people to take time out of their day to stop and smell the (wheat) grass. When one strokes the grass, the sensors are set off and will play calming sound files. We hand-made five switches using copper tubing and piano wire, which were then embedded within the wheat grass. Each sensor set off a different sound files in processing, the sounds included two tibetan bowls playing, chanting and sitar strumming.

The Process:

I did struggle a bit with the programming, having little experience with minim. Using an array of objects, I was able to make the sounds overlap as each sensor was triggered. We also had many different iterations of this project, but ultimately we came back to our original and simplest idea. We did not want to muddle the concept with too much extra fixings. However, I think if I were to add to this project, I would create a zen sand/rock garden surrounded by the grass.

Arduino Code

int digitalTwo = 2;
int digitalThree = 3;
int digitalFour = 4;
int digitalFive = 5;
int digitalSix = 6;

int sensorValue2 = 0;
int sensorValue3 = 0;
int sensorValue4 = 0;
int sensorValue5 = 0;
int sensorValue6 = 0;

void setup() {
// configure the serial connection:
Serial.begin(9600); //starting the serial port
// configure the digital input:
pinMode(digitalTwo, INPUT);
pinMode(digitalThree, INPUT);
pinMode(digitalFour, INPUT);
pinMode(digitalFive, INPUT);
pinMode(digitalSix, INPUT);
}

void loop() { //read 4 digital switches

// read the sensor:

sensorValue2=digitalRead(digitalTwo);
Serial.print(sensorValue2, DEC);
Serial.print(“,”);

sensorValue3 = digitalRead(digitalThree);
// print the last sensor value with a println() so that
// each set of four readings prints on a line by itself:
Serial.print(sensorValue3, DEC);
Serial.print(“,”);

// read the sensor:
sensorValue4 = digitalRead(digitalFour);
// print the last sensor value with a println() so that
// each set of four readings prints on a line by itself:
Serial.print(sensorValue4, DEC);
Serial.print(“,”);

// read the sensor:
sensorValue5 = digitalRead(digitalFive);
// print the results:
Serial.print(sensorValue5, DEC);
Serial.print(“,”);

// read the sensor:
sensorValue6 = digitalRead(digitalSix);
// print the results:
Serial.println(sensorValue6, DEC);
// Serial.println(“,”);

// delay(500);
}

Processing Code:

import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;

//Chant myChant;
//this is the code that we added new variables for colors for PINS 3 and 4

import processing.serial.*; // import the Processing serial library
Serial myPort; // The serial port

int numElements = 3;
Chant [] myElements = new Chant[5]; //did we bring in the class
//Chant=new Chant[3];
Minim minim;

void setup()
{
size(640,480);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(‘\n’);
minim= new Minim(this);
myElements[0] = new Chant(“soundBowls1.wav”, minim); // deep bowl 5 secs
myElements[1] = new Chant(“soundBell3.wav”, minim); //bell 7 secs
myElements[2] = new Chant (“soundWater3.wav”, minim); //water 5 secs
myElements[3] = new Chant(“soundBowlsimple4.wav”, minim); //flat bowls 10 secs
myElements[4] = new Chant(“soundStrumming5.wav”, minim); //6 secs

}
void draw()
{
}
void serialEvent(Serial myPort)
{

// read the serial buffer:
String myString = myPort.readStringUntil(‘\n’);
// if you got any bytes other than the linefeed:
if (myString != null)
{

myString = trim(myString);

// split the string at the commas
// and convert the sections into integers:
int sensor[] = int(split(myString, ‘,’));

// print out the values you got:
for (int i = 0; i < sensor.length; i++)
{ // 4 instead of sensors.length
print(“Sensor ” + i + “: ” + sensor[i] + “\t”);
if (sensor[i]==1)
{
myElements[i].play();

//if sensor i is high then play myElement
}

//check if the value at index i == 1
//if it is, play the sound in the sound array at index i
}
// add a linefeed after all the sensor values are printed:
println();
}
}

void stopSound()
{
for(int i=0; i
{
myElements[i].closeSound();
}
// player.close();

//minim.stop();
super.stop();
}

Tab 2 – Chant

class Chant{

String audioFile;
AudioPlayer player;
Minim minim;

Chant(String _audioFile, Minim _minim)
{
audioFile=_audioFile;
minim = _minim;
player=minim.loadFile(audioFile, 2048);

}
void play()
{
if(!player.isPlaying())
{
player.rewind();
player.play();
}
}
void closeSound()
{
player.close();
minim.stop();
}
}
Prototype:

In the prototype we used an FSR, photocell, and three switches.
DSCN2258

Posted: November 10th, 2009
Categories: PComp
Tags:
Comments: No Comments.

PComp: Serial Communications Lab 2

In this lab we are sending information from the Arduino into Processing.  We can map the sensors we have (here we are using an FSR, photocell, and three switches) to manipulate an image with processing.

Media Controller Iterations from Jenine Durland on Vimeo.

Arduino Code

int analogOne = 0; // analog input
int analogTwo = 1; // analog input
int digitalOne = 2; // digital input

int sensorValue = 0; // reading from the sensor

void setup() {
// configure the serial connection:
Serial.begin(9600);
// configure the digital input:
pinMode(digitalOne, INPUT);
}

void loop() {
// read the sensor:
sensorValue = analogRead(analogOne);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(”,”);

// read the sensor:
sensorValue = analogRead(analogTwo);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(”,”);

// read the sensor:
sensorValue = digitalRead(digitalOne);
// print the last sensor value with a println() so that
// each set of four readings prints on a line by itself:
Serial.println(sensorValue, DEC);
}

——————————————-

Processing Code:

So, initially, I had some issues. I had to change some of the code in order to see the ball. I just changed the color values for the background and fill and then changed the shape. Since I used potentiometers, I changed the values in

xpos = map(sensors[0], 430,580,0,width);
ypos = map(sensors[1], 430,580,0,height);

to

xpos = map(sensors[0], 0,1023,0,width);
ypos = map(sensors[1], 0,1023,0,height);

import processing.serial.*; // import the Processing serial library
Serial myPort; // The serial port

float bgcolor; // Background color
float fgcolor; // Fill color
float xpos, ypos; // Starting position of the ball

void setup() {
size(640,480);

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

// I know that the first port in the serial list on my mac
// is always my Arduino module, so I open Serial.list()[0].
// Change the 0 to the appropriate number of the serial port
// that your microcontroller is attached to.
myPort = new Serial(this, Serial.list()[0], 9600);

// read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(’\n’);
}

void draw() {
background(255,0,0);
fill(fgcolor);
// Draw the shape
rect(xpos, ypos, 60, 60);
}

// serialEvent method is run automatically by the Processing applet
// whenever the buffer reaches the byte value set in the bufferUntil()
// method in the setup():

void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil(’\n’);
// if you got any bytes other than the linefeed:
if (myString != null) {

myString = trim(myString);

// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));

// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
print(“Sensor ” + sensorNum + “: ” + sensors[sensorNum] + “\t”);
}
// add a linefeed after all the sensor values are printed:
println();
if (sensors.length > 1) {
xpos = map(sensors[0], 0,1023,0,width);
ypos = map(sensors[1], 0,1023,0,height);
fgcolor = sensors[2] * 255;
}
}
}

Posted: November 10th, 2009
Categories: PComp
Tags:
Comments: No Comments.

PComp Lab 5: Serial Outputs

Reading serial data - Using an analog sensor (potentiometer) and the arduino, I was able to create a graph of the sensor’s output in Processing.  This exercise illustrated how a sensor’s output corresponds to the physical input on the sensor.

Code in Arduino

int analogPin = 0;
int analogValue = 0;

//Serial myPort;        // The serial port
//int graphXPos = 1;    // the horizontal position of the graph:

void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
// read analog input, divide by 4 to make the range 0-255:
analogValue = analogRead(analogPin);
analogValue = analogValue / 4;
Serial.print(analogValue, BYTE);
// pause for 10 milliseconds:
delay(10);
}

Code in Processing

import processing.serial.*;

Serial myPort; // The serial port
int graphXPos = 1; // the horizontal position of the graph:

void setup () {
size(400, 300); // window size

// List all the available serial ports
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);

background(10,255,65);
}

void draw () {
// nothing happens in draw. It all happens in SerialEvent()
}
void serialEvent (Serial myPort) {
// get the byte:
int inByte = myPort.read();
// print it:
println(inByte);
// set the drawing color. Pick a pretty color:
stroke(123,128,158);
// draw the line:
line(graphXPos, height, graphXPos, height – inByte);

// at the edge of the screen, go back to the beginning:
if (graphXPos >= width) {
graphXPos = 0;
// clear the screen:
background(10,255,65);
}
else {
// increment the horizontal position for the next reading:
graphXPos++;
}
}

//import processing.serial.*;

int analogPin = 0;
int analogValue = 0;

//Serial myPort; // The serial port
//int graphXPos = 1; // the horizontal position of the graph:

void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
// read analog input, divide by 4 to make the range 0-255:
analogValue = analogRead(analogPin);
analogValue = analogValue / 4;
Serial.print(analogValue, BYTE);
// pause for 10 milliseconds:
delay(10);
}

Lab 5: Serial Output from Susan Ngo on Vimeo.

Posted: October 21st, 2009
Categories: PComp
Tags:
Comments: No Comments.

PComp: Very Stupid Pet Trick Second Attempt

It works! (apologies for the terrible video). The shirt in the video below was attempt two. The first shirt I made had 10 LEDs and only three were able to light up, even though the ones not being lit were receiving 2volt according to the multimeter. I figured that I had not sewn the connections between the conductive thread and the LEDs tight enough. However, this shirt I re-sewed making sure all the connections were tight, still only lit up three LEDs. I blame the conductive threat.

Stupid Pet Trick from Susan Ngo on Vimeo.

shirtstitches

The code:

int potPin = 0; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the analog sensor
int led = 9; // voltage from this connection light up all 3 LEDs using a parallel connection

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// declare the led pin as an output:
pinMode (led , OUTPUT); //how to note multiple pins???
}

void loop() {
sensorValue = analogRead(potPin); // read the pot value

// map the sensor value from the input range (200-500 for minimum flex)
// to the output range (0-255). Reversed it so that light is off when sensor is not bent.
int brightness = map(sensorValue, 0, 1023, 0, 255); //starting point off

analogWrite(led, brightness); // set the LED brightness with the result
Serial.println(sensorValue); // print the pot value back to the debugger pane
delay(50); // wait 10 milliseconds before the next loop
}

Next steps – Sound!

Posted: October 6th, 2009
Categories: PComp
Tags:
Comments: No Comments.

PComp Lab 4: Servos

Tools: Arduino, breadboard, RC servomotor, 10k resistors, flex sensor.

Purpose: To control the servomotor using a sensor. I connected the servomotor to digital intput and flex sensor to analog input.

Source code:

int servoPin = 2; // Control pin for servo motor
int minPulse = 500; // Minimum servo position
int maxPulse = 2500; // Maximum servo position
int pulse = 0; // Amount to pulse the servo

long lastPulse = 0; // the time in milliseconds of the last pulse
int refreshTime = 20; // the time needed in between pulses

int analogValue = 0; // the value returned from the analog sensor
int analogPin = 0; // the analog pin that the sensor’s on

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulse = minPulse; // Set the motor position value to the minimum
Serial.begin(9600);
}

void loop() {
analogValue = analogRead(analogPin); // read the analog input
pulse = map(analogValue,0,1023,minPulse,maxPulse); // convert the analog value
// to a range between minPulse
// and maxPulse.

// pulse the servo again if rhe refresh time (20 ms) have passed:
if (millis() – lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulse); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}

Making the Servo Pulse

lab 4: servos from Susan Ngo on Vimeo.

Posted: October 4th, 2009
Categories: PComp
Tags:
Comments: No Comments.

PComp Lab 3: Stupid Pet Trick ABF

The premise of my stupid pet trick: Play on the LUV-O-METER.  When you are at ‘da club’ or even just at the store, you want to make sure you are showing off your muscles.  So, you should Always Be Flexing.

bicep-article-pic-1

I want someone to be able to turn on/off LEDs sewn into the t-shirt they are wearing by flexing their bicep.

To do this I recreated Lab 2 and lit up  an LED using a flex sensor as a switch.  I then line up multiple LEDs wiring in parallel in order for the LEDs to light up  same time using the same power source – Digital 9.  Using the serial monitor, I gauged the threshold of the flex sensor when flexed or unflexed on the arm.

Untitled from Susan Ngo on Vimeo.

Code for flex sensor.

int potPin = 0;    // Analog input pin that the potentiometer is attached to
int sensorValue = 0;   // value read from the analog sensor
int led = 9;    // voltage from this connection light up all 3 LEDs using a parallel connection

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// declare the led pin as an output:
pinMode (led , OUTPUT);  //how to note multiple pins???
}

void loop() {
sensorValue = analogRead(potPin); // read the pot value

// map the sensor value from the input range (200-500 for minimum flex)
// to the output range (0-255). Reversed it so that light is off when sensor is not bent.
int brightness = map(sensorValue, 200, 500, 255, 0);  //starting point off

analogWrite(led, brightness);  // set the LED brightness with the result
Serial.println(sensorValue);   // print the pot value back to the debugger pane
delay(10);                     // wait 10 milliseconds before the next loop
}

Threshold of analogRead needs to be between 350-375.   I need to find code that will read the analog changes in the variable sensor, but OUTPUT with digital code.  DigitalWrite will turn the LED completely on and off instead of just slightly dimming it.

armunflexarmflex

For next week - sewing the LEDs into a shirt and making this sucker portable!  I think I will attempt to use a Lily Pad Arduino

Sneak Preview

IMG_5910IMG_5916heartledglueheartshirt

Posted: September 30th, 2009
Categories: PComp
Tags:
Comments: No Comments.