Archive for » October, 2008 «

Tuesday, October 28th, 2008 | Author: fiona

For this week’s assignment David and decided we would record the ambient noise or environmental sounds in the 5th avenue Apple Store.  We recorded a lot of random conversations, music, concierge name announcements and mostly background noise.  Anatoli is a 1:40 sound piece of the Apple Store’s space or mood.  David compiled the audio tracks in Soundtrack.  The repetition of what sounds like “Anatoli” is the concierge calling out a customer’s name.  We basically used many loops and most of the background music to compile this sound piece.

Anatoli

Category: Comm lab  | Leave a Comment
Tuesday, October 28th, 2008 | Author: fiona

Make Your Own Sountrack

 

For the midterm project I initially wanted to work with audio.  I wanted to do something similar to guitar hero. I wasn’t quite clear what exactly I wanted to do, but I did like the idea of working with audio.  My thoughts then shifted to the piano.  I received some suggestions in class about maybe allocating certain keys to certain piano sounds.  Since having only one week to work on this project, the idea of “Make Your Own Soundtrack” is very very basic and will be worked on as a larger scale in the future.  

I downloaded some piano audio clips and saved them into the data folder.  In writing the code, keys A,S,D,F,J,L would play a specific sound file when pressed. 

After having downloaded and installed the minim library, I tweaked the sample code to my liking.  The original code would not compile.  Then I found out that I had to use objects in the first part of the code. The only other changes I made were to the audio files, and initializing a keyPressed function for each audio clip.  The initial code would play the audio file once.  Therefore, adding a rewind and play function would allow the user to press the key as many times as needed for audio playback.

 

There was another code for a waveform of the audio that I also incorporated into the first part of my final code.  

 

Below are some pictures of what the waveform looks like upon playing an audio file.  

    

This site was very helpful for installing and using the Minim Library

http://code.compartmental.net/tools/minim/

 

 

Here is my final code.  

 

import ddf.minim.*;

import ddf.minim.analysis.*;

 

Minim minim;

AudioPlayer groove;

FFT fft;

 

void setup(){

  size(512, 400);

  minim = new Minim(this);

  groove = minim.loadFile(“piano.mp3″, 512);

 

}

 void draw(){

  background(0);

  fft = new FFT(groove.bufferSize(), groove.sampleRate());

  fft.forward(groove.mix);

  stroke (255,0,0,128);

  for(int i = 0; i < fft.specSize(); i++)

  {

    line(i, height, i, height – fft.getBand(i)*4);

  }

 

  stroke(255);

for(int i = 0; i < groove.left.size() – 1; i++)

  {

    line(i, 50 + groove.left.get(i)*50, i+1, 50 + groove.left.get(i+1)*50);

    line(i, 150 + groove.right.get(i)*50, i+1, 150 + groove.right.get(i+1)*50);

 

  }

}

 

 void keyPressed() {

   if (key == ‘a’ || key == ‘A’) {

       println (“playing groove 1″);

       groove = minim.loadFile(“piano.mp3″, 512);

       groove.rewind();

       groove.play();

 

   } else if (key == ’s’ || key == ‘S’) {

      groove = minim.loadFile(“piano1.mp3″, 512);

       println (“playing groove 2″);

       groove.rewind();

       groove.play();

 

   } else if (key == ‘d’ || key == ‘D’) {

      groove = minim.loadFile(“piano2.mp3″, 512);

       println (“playing groove 3″);

       groove.rewind();

       groove.play();

 

    } else if (key == ‘f’ || key == ‘F’) {

      groove = minim.loadFile(“piano3.mp3″, 512);

       println (“playing groove 4″);

       groove.rewind();

       groove.play();   

 

     } else if (key == ‘j’ || key == ‘J’) {

      groove = minim.loadFile(“piano4.mp3″, 512);

       println (“playing groove 5″);

       groove.rewind();

       groove.play();

 

        } else if (key == ‘k’ || key == ‘K’) {

      groove = minim.loadFile(“piano5.mp3″, 512);

       println (“playing groove 6″);

       groove.rewind();

       groove.play();

 

        } else if (key == ‘l’ || key == ‘L’) {

      groove = minim.loadFile(“piano6.mp3″, 512);

       println (“playing groove 7″);

       groove.rewind();

       groove.play();

 

 

      }

 }

 

On a larger Scale I want to create some type of game such as a guitar hero where the user matches up audio cues.

Category: ICM  | Leave a Comment
Friday, October 24th, 2008 | Author: fiona

For this week’s lab i decided to do the H-brigde lab. The purpose of this lab is to control the direction of the DC motor.

The first step was connecting the breadboard to power and ground as usual and then adding a pushbutton switch and connecting it to digital input 2 on the Arduino.

This lab uses the SN754410 H-bridge.

This particular chip has 4 half-H bridges, and can therefore control 2 motors. It can drive up to 1 amp of current, and between 4.5 and 36V. This H-bridge has two bridges, one on the left and right side of the chip.
According to the lab, every H-bridge has the same basic features; pins for Logic input, motor supply voltage, logic voltage, motor supply output and pins for ground.  The lab was a little confusing for me.  I followed the schematic portion of the lab, but I became a little confused as to whether it was supposed to resemble the picture included.  I also did not know that the notched part of the Hbridge was supposed to point up on the breadboard.  

The first part of the lab was pretty straightforward with connecting the pushbutton switch. 

 

The second part of the lab failed me the first time I wired everything up and ran the code.

 

Looking at the code as compared to what the schematic displayed confused me a little.  

 

 

int switchPin = 2;    // switch input
int motor1Pin = 3;    // H-bridge leg 1
int motor2Pin = 4;    // H-bridge leg 2
int speedPin = 9;     // H-bridge enable pin
int ledPin = 13;      //LED 
The bolded part of the code confused me as compared to the picture of where everything was
supposed to go.  Below is the rest of the code.  Eventually the motor worked and I realized I had
the pin plugged into 3 volts and not 5.
void setup() {
  // set the switch as an input:
  pinMode(switchPin, INPUT);

  // set all the other pins you're using as outputs:
  pinMode(motor1Pin, OUTPUT);
  pinMode(motor2Pin, OUTPUT);
  pinMode(speedPin, OUTPUT);
  pinMode(ledPin, OUTPUT);

  // set speedPin high so that motor can turn on:
  digitalWrite(speedPin, HIGH);

  // blink the LED 3 times. This should happen only once.
  // if you see the LED blink three times, it means that the module
  // reset itself,. probably because the motor caused a brownout
  // or a short.
  blink(ledPin, 3, 100);
}

void loop() {
  // if the switch is high, motor will turn on one direction:
  if (digitalRead(switchPin) == HIGH) {
    digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
    digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high
  }
  // if the switch is low, motor will turn in the other direction:
  else {
    digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
    digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low
  }
}

/*
  blinks an LED
 */
void blink(int whatPin, int howManyTimes, int milliSecs) {
  int i = 0;
  for ( i = 0; i < howManyTimes; i++) {
    digitalWrite(whatPin, HIGH);
    delay(milliSecs/2);
    digitalWrite(whatPin, LOW);
    delay(milliSecs/2);
  }
}

Category: PhysComp  | Leave a Comment
Friday, October 24th, 2008 | Author: fiona

Fiona D.
Aaron Uhrmacher  Aaron\’s Blog
David Golan David\’s blog

We are in our last week of the Interactive Elevator. A lot of ups and downs….a lot of both failed and successful attempts. However, the elevator was a huge success and we all worked together quite well to bring some type of interaction to this otherwise boring space called an elevator. 

Although we were very successful, we often encountered problems were unsure as to whether it was the code or the components we were using.  We came to the conclusion that our structure was not very stable and could be a contributing factor to some of those failed trials.  We used little methods to get around some of our problems.  We placed scotch tape over the photocells for the purpose of spreading the laser beam, which worked out quite well actually.  The casing for our lasers held the lasers in place.  Sometimes we had a finagle with the laser position to make it point directly unto the laser

 Nevertheless, we were victorious in seeing our work in action and working the way it was supposed to. 

This week we were faced with the daunting task of combining both the Waveshield/Audio with the break-beam code.  We decided to use a force sensor to trigger the audio cues.  We planned for the code to work in such a way that the beam would count the number of people entering the elevator; based on this, the door would close triggering the sensor and calling the audio cue allocated to the number of people in the elevator.  Here are some more audio cues that were recorded (several Audio cues are included in week 2’s post.)

Audio clip1

Audio Clip2

Audio Clip3

Audio Clip4

People that listened to these audio cues, thought they were pretty funny.

We were all very excited to use the Waveshield. The instructions on the Lady Ada instructed us to change our audio files into  uncompressed 22KHz, 16bit, mono Wave (.wav) files.  I looked up the audio shield library and found some sample code.  After having much done much research on the Arduino waveshield we had intentions of this piece performing as it did in the video below.

 

http://ladyada.net/make/waveshield/faq.html

 

HOWEVER, when we attempted to use the waveshield we received an error or a failed attempt error.  I double checked to see if all of the right pieces were in tact (everything seemed to be in tact).  This was very frustrating as we invested money and were excited to use this part.  The Waveshield is fairly new on the market and not much people around ITP knew much about how it works.  

Therefore, we decided that our time would be better spent not worrying about how to get this piece to work.  We instead decided to use the Minim library.
 

http://code.compartmental.net/tools/minim/

 

We went through all of the motions of downloading the minim library and evaluating our code. We tested the code on its own to see if it was able to play the audio cues first and then implemented our serial communication knowledge to merge both Arduino and processing.

We also messed around some more with the construction.  We still settled upon using foam but tried to brainstorm ideas to make the structure much more stable and level.  


We taped off an area by a door in order to simulate an elevator space.  We also placed the FSR (force sensing resistor) on the door frame with the intent that the closing the door would trigger the sensor.  

Below are our photocells.  The laser beams on the other side of the door would directly be hitting these photocells.  

    

Our week consisted of testing and retesting.  As far as our structure goes, we initially had the senros at leg level but then realized that each sensor might be tripped twice with each leg.  Therefore we moved the sensors chest level to ensure that we would receive a more accurate reading.  Sometimes it worked perfectly and sometimes it didn’t.  We often had to change the threshold of the FSR so that it registered some type of values that it was pressed.  In talking to some people at ITP, we were advised that FSR’s are not the most reliable sensors to use for this type of testing and retesting as they are very delicate.

 

 We set up a video camera and recorded all of our trials, in hopes that it would work a few times for documentation purposes.  Below is the demo video of the few times when our project was a success and also a demo of what we hope this project will accomplish. 

 

 

 

We also decided that our elevator needed a name.  A name to go along with that pre-recorded voice that all three of us grew so fondly of hearing =].  We decided to name him “VANCE”, which is an acronym for Voice Automated Number Counting Elevator.  For presentation purposes, VANCE proved to be very friendly.  

 

We also took into consideration people that were using crutches, wheelchairs, hearing impairments or anything that might cause this experience to be one in which it was not intended.  However, we do see this as a project that we can work on long term..maybe as a final project and hope to take any other factors into consideration.  

}

Here is the Processing code for the Audio (Processing)

 

import ddf.minim.*;

import processing.serial.*;

 

Minim minim;

AudioPlayer song;

Serial myPort;

 

void setup() {

  minim = new Minim(this);

  //println(Serial.list());

  myPort = new Serial(this, Serial.list()[0], 9600);

}

 

void draw() {

}

 

void serialEvent(Serial myPort) {

  int inByte = myPort.read();  //inByte = counter!

  println(inByte);

  playMyAudio(inByte);

void playMyAudio(int numPeople) {  //numPeople can only be 1-4

  int randAudio;

  if (numPeople == 2) randAudio = int(random(1, 5));  //1-4

  else randAudio = int(random(1, 6));  //1-5

  song = minim.loadFile(numPeople + “” + randAudio + “.wav”);

  song.play();

void stop() {

  song.close();

  minim.stop();

  super.stop();

}

Here is the final code for Arduino using the FSR and break-beam.
int photoPin0 = 0; //Photocell in analog input pin 0  (ranges from 0-750)
int pv0 = 0;  //photoValue0
int photoPin1 = 1;  //Photocell in analog input pin 1
int pv1 = 0;  //photoValue1
int threshold = 100; //threshold for photocells – used to be 500
int fsrPin = 2;  //force sensor in analog pin 2
int fsrv = 0;  //fsr value
int x = 0;  //simple variable that helps with loop
int increment = 1;  //increment for the counter
int counter = 1; // Counter that is used to record the amount of people
void setup() {
  Serial.begin(9600);
}
void loop() {
  while (!checkFSR()) {  //while FSR is not being pushed
    while (!check0() && !check1()) {  // lit/clear = !check0 && !check1
      //Serial.print(“counter: “);
      //Serial.println(counter);
      //Serial.println(“A and B lit – clear”);
    }
    if (check0()) {
      //Serial.print(“A val= “);
      //Serial.println(pv0);
      //Serial.println(“A tripped”);
      //Serial.println(“A tripped — B still lit”);
      while (!check1()) {
        //do nothing
        //Serial.print(“counter: “);
        //Serial.println(counter);
      }
      //Serial.print(“B val= “);
      //Serial.println(pv1);
      //Serial.println(“A tripped — B now tripped!”);
      while (check1()) {
        //do nothing
        //Serial.print(“counter: “);
         //Serial.println(counter);
      }
      counter++; 
      //Serial.print(“counter: “);
      //Serial.println(counter);
    } 
    else if (check1()) {  //if B tripped
      //Serial.print(“B val= “);
      //Serial.println(pv1);
      //Serial.println(“B tripped”);
      //Serial.println(“B tripped — A still lit”);
      while (!check0()) {  //while A is lit
        //do nothing
        //Serial.println(counter);
      }
      //Serial.print(“A val= “);
      //Serial.println(pv0);
      //Serial.println(“B tripped — A now tripped!”);
      while (check0()) {  //while A is tripped
        //do nothing
        //Serial.println(counter);
      }
      counter–; 
      //Serial.print(“counter: “);
      //Serial.println(counter);
    }
  }
  x = 0;
  if (counter < 0) counter = 0; //just in case!
  else if (counter > 4) counter = 4;
  while (checkFSR()) {
    if (x == 0) {   //run this code just once when FSR is pushed; wait until FSR no longer pushed
      if (counter >=1 && counter<=4) Serial.print(counter, BYTE);  //only print if 1-4 people
      x = 1;
    }  //do nothing in while loop once running if-statement once
  }
}
boolean check0() {
  pv0 = analogRead(photoPin0);
  if (pv0 < threshold) return true;   //trip
  else return false;   //lit
}
boolean check1() {
  pv1 = analogRead(photoPin1);
  if (pv1 < threshold) return true;   //trip
  else return false;    //lit
}
boolean checkFSR() {  //returns true if elevator door closed with 1-4 persons
  fsrv = analogRead(fsrPin);
  //Serial.println(fsrv);
  if (fsrv > 110) {  //FSR Threshold of 110  - fsr pushed!
    return true;
  } 
  else return false;  //fsr not pushed
}
Category: PhysComp  | Leave a Comment
Thursday, October 23rd, 2008 | Author: fiona
Fiona Daniels
Aaron Uhrmacher  Aaron\’s Blog
David Golan
INTERACTIVE ELEVATOR—WEEK 2

During week two of our interactive elevator midterm we bought some supplies that would get us on our way to building the main components for our elevator.

1. photocells (radio shack…or can be found at the bookstore)

2. Laser pointer (Canal street)

We initially were going to build an entire elevator but later decided that we weren’t going to in an effort to save money and spend it on other important parts of the “elevator.”  Therefore, we decided to build a small wooden model that would hold both the photocells on one side and the lasers on the other. The first picture is a rough simulation of how the pieces would go.  The second picture is one side of the model holding the lasers and the third picture is holding the photocells.

While the wooden pieces were drying (we used wood glue) we worked on some code for getting the laser beam or “break beam” to count the number of people entering and exiting the elevator.  As the picture shows,

The first round of testing the “break beam” code we used 4 LED’s in order the simulate the passengers.  We also placed photocells on the breadboard in order to simulate the breakbeam.  Whenever we directed the laser onto the photocell and broke the beam, one of the LED’s would light up.  With each break of the beam, more LED’s would light up (signifying more people on the elevator. )

The Waveshield also arrived on time ($22.00)  As explained in week 1’s blog, the purpose of the Waveshield is to play audio without having to connect directly to the computer.  By hooking up the Arduino to the Waveshield, it can be powered externally, eliminating the need for computer attachment.  The Waveshield contains an SD card input for storing and playing audio files.  The Waveshield also came with its own kit which contains many pieces that need to be soldered together. The Lady Ada Waveshield site is referenced in week 1’s blog post.

Aaron had a friend come in and record the audio tracks for playback in the elevator.

Here are a few of the clips recorded

Elevator Audio Clip 1

Elevator Audio Clip 2

Elevator Audio Clip 3

We went through several materials trying to find something that would accurately hold the photocells and lasers.  We then decided to use foam.  For testing purposes we used a doorway to simulate the elevator space.

Photocells w/ laser beam
Photocells w/ laser beam

lasers
lasers

We aligned the beams with the photocells. The beam on the left side counts the number of people entering and the beam on the right counts the number of people exiting.  One of the most consistent challenges that we had was to keep the beam directly on the photocells. Also, we encountered the problem of batteries dying or becoming weak during our trial testing.  We couldn’t test our construction in an actual elevator . Initially we were going to use IR sensors, but realized after talking to several people that photocells would be a better choice.

This is the code from our first round of testing the break-beam with the LED’s (picture above)

int ledPin[ ] ={1,2,3,4}; // LED connected to digital pin1-7  //FOR TESTING PURPOSES!
int photoPin0 = 0; //Photocell in analog input pin 0  (ranges from 0-750)
int photoPin1 = 1;  //Photocell in analog input pin 1
int threshold = 500;
int counter = 0; // Counter that is used to record the amount of people
void setup() {
Serial.begin(9600);
pinMode(1, OUTPUT); // sets the digital pin1-4 as output
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
while (!check0() && !check1()) {  //clear = !check0 && !check1
Serial.println(counter);
for(int i=1; i<=counter; i++) {
digitalWrite(ledPin[i-1], HIGH);
}
}
if (check0()) {
while (!check1()) {
//do nothing
}
while (check1()) {
//do nothing
}
counter++;
}
else if (check1()) {
while (!check0()) {
//do nothing
}
while (check0()) {
//do nothing
}
counter–;
}
}
boolean check0() {
if (analogRead(photoPin0) > threshold) return true;
else return false;
}
boolean check1() {
if (analogRead(photoPin1) > threshold) return true;
else return false;
}
Here is the code for the break-beam that we set up on the door
int ledPin[ ] ={1,2,3,4} ; // LED connected to digital pin1-7
//int switchPinA = 12;
//int switchPin = 13; // Break beam sensor connected to digital pin 13
int photoPin = 0; //Photocell in analog input pin 0  (ranges from 0-750)
int photoValue = 0;
int counter = 0; // Counter that is used to record the amount of people
//int interrupt = 0; // the state “interrupt” of the system: somebody pass by the sensor
//int steady = 1; //the state “ steady” of the system: no one pass by the sensor

void setup() {
Serial.begin(9600);
pinMode(1, OUTPUT); // sets the digital pin1-7 as output
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
//pinMode(switchPin, INPUT); //sets the switchPin as input
}

void loop() {
photoValue = analogRead(photoPin);
while(doorClear()) {
photoValue = analogRead(photoPin);
Serial.println(photoValue);
for(int i=0; i<=counter; i++) {
digitalWrite(ledPin[i], HIGH);
}
}
while(!doorClear()){
photoValue = analogRead(photoPin);
}
counter++;

/*while(doorClear()) { // if the doorClear is true: in the doorClear state
//Serial.println(digitalRead(switchPin));
for(int i = 0; i <= counter; i++){
digitalWrite(ledPin[i], HIGH); // sets the LED on
}
}
while(doorBlock()){ // if the doorBlock is true: in the doorBlock state
// do nothing
}
counter++; // add 1 to the counter…  */
}

boolean doorClear() {
if (photoValue > 500) return true;
else return false;
}

/*boolean doorClear() {
return digitalRead(switchPin) == steady; // return true if the value of switchPin is the same as steady
}

boolean doorBlock() {
return digitalRead(switchPin) == interrupt; // return true if the value of switchPin is the same as interrupt
}
*/

Aside from the code, building was a big part of this project as well.  We were aware that our break-beam is not perfect and can be tripped more than once by one person maybe due to any significant amount of movement or baggage that person may have.  However, for the purpose of this project and the short length of time to do it in, every person that walks by the laser is equal to 1.
Here are some of the sites that were useful to us.
DAVID                                                  Aaron                                                 Me & David

NEXT STEPS!!!!
  1. Setting up the waveshield
  2. continue work on code. Combining break-beam with Audio cues
  3. Improve construction
  4. DOCUMENT!!!!
Category: PhysComp  | Leave a Comment
Tuesday, October 21st, 2008 | Author: fiona

McLuhan- Understanding Media

 

Some of Mcluhan’s reading were sometimes difficult for me to internalize.  I have always thought of medium as sort of a channel or object that people used to get their messages across.   It was almost as if I had to forget about what I have learned during my undergraduate years when we discussed television, and advertising and internet as mediums for people to communicate.  “Electric light” is one of the examples used as a medium.  Mcluhan stressed thinking about light as a “medium without a message.”  I had to re-read chapter one to really get an understanding of what Mcluhan was trying to say.  I eventually got that any form of medium is a derivative of another medium.  The example that struck me the most was how an abstract painting represents “a direct manifestation of a creative thought process.”  The medium according to Mcluhan is simply the change in human society or events.  I went back and forth with this notion in my head for a little while.  

McLuhan mentions that a medium is an extension  of man.  This related to other things that Mcluhan discussed where technology or any object is only as good or bad as we make them.  We frequently hear the arguments about firearms or the people that use them being good or bad (also discussed in the reading).  It reminds me of the people who file lawsuits against fast food chains claiming that the food caused their weight gain…not realizing that the weight gain probably came from ingesting fast food all day long.  I guess some things in this reading were harder to grasp than others.  

 

Just a side note that I immediately thought of Clay Shirkey’s book, Here Comes Everybody when reading some of McLuhan chapter 1.  More specifically  the comment made by Napoleon in saying “Three hostile newspapers are more to be feared than a thousand bayonets.”  The first chapter in Here Comes Everybody speaks about the power of different mediums to cause a movement that would otherwise go unnoticed.  When a woman lost her cell phone, she was able to retrieve it with the help of thousands of bloggers and one guy who decided to use the internet as a way to spark an emotional interest in people hundreds of miles away. After tracking the person who was in possession of the lost phone (and reluctant to return the phone), she was immediately subjected to harassment and and other forms of threats.  Eventually, the girl who found the phone was arrested (something that seldom happens).  The police department was even put into a position of having to take action due to the “outcry” from various people who expressed outrage that the founder of the phone was not forced to return it.  The internet being as popular today as newspapers were then, caused people to think about something that normally wouldn’t be given a second thought.

Category: Comm lab  | Leave a Comment
Wednesday, October 15th, 2008 | Author: fiona

 

Serial lab #2

The purpose of this lab is to demonstrate how to send data from multiple sensors to a program on the computer (processing).  The example in this lab used an accelerometer.  However, if we did not have an accelerometer, we could also use two analog sensors and a push button switch. The pot’s controlled the X and Y axis position and the switch controlled the color of the ellipse.

The first step is to wire the breadboard to the Arduino. Instead of using the accelerometer, i wired up the two potentiometers as usual and then the pushbotton. The pushbutton went to digital pin 2.  The potentiometers went to analog pins 0 and 1.  

 

The code for the arduino is as follows

 

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);
}

 

After uploading the code to the Arduino, the next step was the run a program in processing.  The code in processing reads the data from the Arduino program.  Setting up this code was a little confusing for me, as I followed each group of code in detail.  However, when i compared my code to the final code in its entirety, i was missing certain things.  Since the code was made for an accelerometer, we had to change the last bit of code so that it can correspond to having two pot’s and a pushbutton.  

 

Here is the sample code with the ending of the code values changed and in bold. 

 

 

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(bgcolor);
  fill(fgcolor);
  // Draw the shape
  ellipse(xpos, ypos, 20, 20);
}

// 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;
    }
  }
}
   
The first screenshot are the sensor values when the pot's are turned and the pushbutton is 
pressed. Sensor 0 and 1 are the pot. value.  The pushbutton corresponds to sensor 2, which
only gives off 0 and 1 as its value since it is a digital switch.
Get Creative
Looking at the two potentiometers, I was reminded of an etch-a-sketch.  Therefore, it would be 
fitting to create a computer version of an etch-a-sketch, where the pots were used to draw lines 
Category: PhysComp  | Leave a Comment
Wednesday, October 08th, 2008 | Author: fiona

Our project is the creation of an interactive elevator using motion cues to trigger audio and video element to make for a more relaxed and uneasy elevator ride.  It is widely known that when people get on an elevator they are usually quiet while waiting for to reach their respective floors.  If there is any type of interaction, it is usually between people that already know each other. The purpose of this project is to spark two levels of interactivity between persons using the elevator or between the person on the elevator and the audio/video elements within the elevator.  When standing in the elevator, people are most likely to stare down at the floor, up at the ceiling or at the elevator floor meter.     

Our first step was to sketch out a picture of how the elevator would look and roughly where we would place our components.  Our make-shift elevator would hold approximately three to four people (similar to the smaller of the two left side elevators at Tisch). The dimensions we measured the elevator to be are 57X47X95 (HLW)

Materials needed:     

  1. Plastic PVC piping (elevator frame)
  2. Fabric (elevator walls)
  3. Infrared Sensors (cue for audio/visual components when person walks in)
  4. Speaker – (audio)
  5. video monitor- (visuals)
  6. button/box- (to simulate elevator control panel where buttons are also used for triggering audio/visual components.)
  7. Force sensors (put on elevator floor that can also trigger audio/visual components.

In our meeting we discussed alternate ways of triggering the audio/visual cues.  The IR sensors would be placed at the door to maybe keep count of how many people enter the elevator.  The IR sensors would trigger the audio component to say facts about the number of people on the elevator, campus events, jokes etc).   The force sensors would be placed at different parts on the elevator floor labelled “A”, “B” “C”, “D” (this particular one would most likely be for a body count of 1 or two people) with the intentions of using the sensors as a response mechanism to the questions posed either on the monitor or heard through the audio outputs. Interaction may be determined by the length of the ride or number of people in elevator.

     

We then rode the smaller elevator to observe interaction and timing between floors.  About five seconds elapsed between the time the elevator closed and reached the next floor.  !0 seconds elapsed if we counted the time the elevator closed to the time it opened.  We stayed on for about 5 minutes just to observe more people’s interaction on the elevator.  We noticed that a lot of the interaction between people took place when they boarded the elevator already knowing each other.  Everyone else stood in silence waiting for the elevator to reach its destination.  As for Aaron, David and I, much of our interaction were between each other and sometimes with others.  We Then measured the actual dimensions of the elevator.  We came up with many ideas for what elements to include in our “elevator” and which ones would be most feasible based on our current skill sets and resources.  

 

 

We also did some research on anything that can aid us in making this project successful.  We were referred to a site showing how an Arduino breadboard can be used to add music to an Arduino.  

Arduino shield website

 

 

We have a lot more research to do.  The next task is programming, building and testing our prototype

Category: PhysComp  | Leave a Comment
Wednesday, October 08th, 2008 | Author: fiona

Serial Out

The first part of the lab was pretty straightforward. I hooked up the breadboard the same as I did in the analog lab, using analog pin 0 to connect the potentiometer (analog sensor).

The arduino was programmed as follows

int analogPin = 0;
int analogValue = 0;

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);
}

After compiling and uploading the code to the IO board, turning on the serial monitor and turning the Potentiometer’s knob; the serial monitor displayed a series of question marks and a lot of other characters. These characters were basically the raw binary value of the byte. After receiving the readings from the potentiometer, the characters produced are basically the ASCII characters that correspond to the values that the monitor receives.  

 

The second thing the lab instructed me to do was import the Processing Serial Library (in Processing). which we can ether type out or by selecting sketch–>import library –>serial.

 

import processing.serial.*;

 

 

Graphing the sensor’s values

The rest of the lab was done step by step explaining the purpose of many lines of code.

 

 

Sensor Graphing Sketch

 This sketch takes raw bytes from the serial port at 9600 baud and graphs them.

 Created 20 April 2005
 Updated 5 August 2008
 by Tom Igoe
 */

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());
  // I know that the fisrt port in the serial list on my mac
  // is usually my Arduino module, so I open Serial.list()[0].
  // Open whatever port is the one you're using.
  myPort = new Serial(this, Serial.list()[0], 9600);

  // set inital background:
  background(48,31,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(48,31,65);
  }
  else {
    // increment the horizontal position for the next reading:
    graphXPos++;
  }
}

 

The most exciting part of this lab was actually seeing how the graph change when the potentiometer was turned.

Category: PhysComp  | Leave a Comment
Monday, October 06th, 2008 | Author: fiona

Category: Comm lab  | Leave a Comment