Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


Assignment #5 Input/Putput Object: A Rubber Sculpture

Project Members: 
Seung Wan Hong
Description

I put FRSs,a green LED, and a Piezo Speaker inside a half opacity rubber sculpture. If I will push FRSs inside the sculpture, light and sound will be generated in it. In other wards, the sculpture is a pakage to make an Input/Output product.

Components

A rubber Sculpture, a green LED, FSRs, a Piezo Speaker, Arduino Board, Bread Board, wires,

Arduino Codes

 int fsrIn = 0;    // the inputpin for FSRs
int gOut = 9;   // goes to Green LED
int fsrVal = 0;   // Variables to store the input from FSRs
int speakerPin = 7;
int soundval = 0;

int i = 0;            // Loop counter
int wait = (1000);    // Delay between most recent pot adjustment and output

int checkSum     = 0; // Aggregate pot values
int prevCheckSum = 0;
int sens         = 3; // Sensitivity theshold, to prevent small changes in
                      // pot values from triggering false reporting
// FLAGS
int PRINT = 1; // Set to 1 to output values
int DEBUG = 1; // Set to 1 to turn on debugging output

void setup()
{
  pinMode(gOut, OUTPUT);   // sets the digital pins as GreenLED
  Serial.begin(9600);     // Open serial communication for reporting
  pinMode(speakerPin, OUTPUT);
  beginSerial(9600);
  Serial.println("ready");
}

void loop()
{
  i += 1; // Count loop

  fsrVal = analogRead(fsrIn) / 4;  // read input pin1, convert to 0-255 scale
  analogWrite(gOut, fsrVal);    // Send new values to GreenLED

  if (i % wait == 0)                // If enough time has passed...
  {   
    checkSum = fsrVal+fsrVal;           // ...add up the 2 values.
    if ( abs(checkSum - prevCheckSum) > sens )   // If old and new values differ
                                                  // above sensitivity threshold
    {
      if (PRINT)                    // ...and if the PRINT flag is set...
      {
        Serial.print("A: ");        // ...then print the values.
        Serial.print(fsrVal);        
        Serial.print("\t");
       
       
        PRINT = 0;
      }
    } 
    else
    {
      PRINT = 1;  // Re-set the flag  
    }
    prevCheckSum = checkSum;  // Update the values

    if (DEBUG)   // If we want debugging output as well...
    {
      Serial.print(checkSum);
      Serial.print("<=>");
      Serial.print(prevCheckSum);
      Serial.print("\tPrint: ");
      Serial.println(PRINT);
    }
}
digitalWrite(speakerPin, LOW);
 
  soundval = analogRead(fsrIn);    // read value from the sensor
  soundval = soundval*2;                 // process the value a little
  //val = val/2;                 // process the value a little
  
  for( int i=0; i<500; i++ ) {  // play it for 50 cycles
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(soundval);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(soundval); 
}
}


AttachmentSize
a rubber scuplture01.jpg133.17 KB
a rubber scuplture02.jpg80.17 KB
a rubber scuplture03.jpg51.25 KB
the other application.jpg45.54 KB

Powered by Drupal - Design by Artinet