Making Things Interactive

May 12, 2008

BOOMBOXES

Filed under: Assignments, Final Project, Jesse Chorng, Paul Castellana — paulcastellana @ 2:44 pm

Boomboxes is an environment designed to promote social interaction through music. It consists of a stationary hub, and five wireless modular seating units that can be moved and stacked to best fit the given social situation. Users can connect their mp3 players to an input jack in the hub to play music through all of the modular units. Each unit has a radio, RBG and white lights, a seat button that detects when someone is sitting down, and all are networked together using Xbee radio transmitters. Although a faulty seat button caused malfunctioning during the final presentation, the particular program we’re providing code for here changes the lighting of the boxes based on the number of people sitting down, so that when music is playing and the boxes are activated, the lights are white until all five boxes are in use, at which point each box lights a different color. If at this point, everyone stands up within 15 seconds of each other the colored lights dances to the music.

Project Website which is currently under construction. For now, check it out here

Here’s our proposal: Boomboxes Proposal

Part’s List: Boomboxes Parts List

Code:

/*
Boomboxes - Social Interaction Through Music
Small Undergraduate Research Grant

Paul Castellana
Jesse Chorng

*/

//----------- STATES ------------//
const int sWaiting = 0;          // The system is waiting for audio to be plugged in. Speakers/Lights are off
const int sActivate = 1;         // The system detects audio being played. Speakers/Lights are on
const int sAttract = 2;          // The system detects motion and inactive; lights turn to attract attention
const int sStandby = 3;          // If everyone sitting and someone stands up, wait 30 secs to see if everyone stands up
const int sParty = 4;            // If there's enough people around and people are moving, party time! Lights dance to music

int currentState = sWaiting;
int nextState = sActivate;

//----------- INPUTS ------------//
int audioIn = 1;                 // Audio signal in from stereo jack
int activateSwitch = 9;          // Switch to activate Boomboxes
int pirSensor = 8;               // PIR Motion swich, sends LOW when motion detected

int seat1 = 6;                   // Input Pin for Seat 1
int seat2 = 5;                   // Input Pin for Seat 2
int seat3 = 4;                   // Input Pin for Seat 3
int seat4 = 3;                   // Input Pin for Seat 4
int seat5 = 2;                   // Input Pin for Seat 5

//----------- OUTPUTS -----------//
int recModuleSwitch = 10;        // Seat switch to know when someone is sitting
int radioSwitch = 7;             // Activates radios in seats
int rgbLed = 12;                 // RGB LED
int whiteLed = 11;               // White LED

//---------- VARIABLES ----------//
int motionCount = 0;             // PIR Motion Count
int allSitting = 0;              // All sitting true (1) or false (0)
int allStanding = 0;             // All standing true (1) or false (0)
int audioVal;

//--------------------------- SETUP ---------------------------//
void setup()  {

    pinMode(audioIn, INPUT);
    pinMode(activateSwitch, INPUT);
    pinMode(pirSensor, INPUT);
    pinMode(seat1, INPUT);
    pinMode(seat2, INPUT);
    pinMode(seat3, INPUT);
    pinMode(seat4, INPUT);
    pinMode(seat5, INPUT);

    pinMode(recModuleSwitch, OUTPUT);
    pinMode(radioSwitch, OUTPUT);
    pinMode(rgbLed, OUTPUT);
    pinMode(whiteLed, OUTPUT);

    Serial.begin(9600);
}

//---------------------------- LOOP -----------------------------//
void loop()  {

  switch(currentState) {
       case sWaiting:                                            // Waiting to either activate or attract people
           Serial.println("Waiting");

           digitalWrite(radioSwitch, LOW);                       // Radios are off
           digitalWrite(recModuleSwitch, LOW);                   // Don't play "Boomboxes" sample
           digitalWrite(whiteLed, LOW);                          // No LED action
           digitalWrite(rgbLed, LOW);                            // No color LED action

           if (digitalRead(activateSwitch) == HIGH) {            // Check switch to activate
               currentState = sActivate;
           }

           motionCheck();                                        // Check for motion from PIR sensor
           if(motionCount > 30) {                                // If there's enough motion, go into Attract state
             currentState = sAttract;
           }
           break;

       case sAttract:
           Serial.println("Attract");

           digitalWrite(radioSwitch, HIGH);
           digitalWrite(recModuleSwitch, HIGH);
           digitalWrite(whiteLed, LOW);

           motionCount = 0;

           for(int h=0; h < 10; h++) {                            // When in attract mode, flash lights for 15 secs
             digitalWrite(rgbLed, HIGH);
             delay(500);
             digitalWrite(rgbLed, LOW);
             delay(500);
           }

           if(digitalRead(activateSwitch) == HIGH) {
             currentState =sActivate;
           } else {
             currentState = sWaiting;
           }

           break;

       case sActivate:                                            // Activated mode is simply white LEDs on
           Serial.println("Activated"); 

           digitalWrite(radioSwitch, HIGH);
           digitalWrite(recModuleSwitch, LOW);
           digitalWrite(whiteLed, HIGH);
           digitalWrite(rgbLed, LOW);

           if (digitalRead(activateSwitch) == LOW) {
             currentState = sWaiting;
           }       

           allSittingCheck();                                      // If all 5 seats are occupied, go to
           if(allSitting == 1) {                                   // Standby mode before Party state
             currentState = sStandby;
           }
           break;

       case sStandby:
           Serial.println("Standby to Party");

           digitalWrite(radioSwitch, HIGH);
           digitalWrite(recModuleSwitch, LOW);
           digitalWrite(whiteLed, LOW);
           digitalWrite(rgbLed, HIGH);

           allSittingCheck();

           if (allSitting == 0)  {                                  // If everyone is sitting there is
             for(int f=0; f<15; f++) {                              // 15 secs to go into Party State
               digitalWrite(whiteLed, HIGH);
               delay(500);
               digitalWrite(whiteLed, LOW);
               allStandingCheck();
               if(allStanding == 1) {
                 f = 15;
                 currentState = sParty;
               }
               delay(500);
             }
             allSittingCheck();
             if(allSitting == 0) {
               currentState = sActivate;
             }
           }

           if (digitalRead(activateSwitch) == LOW) {
           currentState = sWaiting;
           }

           break;

       case sParty:
           Serial.println("Party!");

           digitalWrite(radioSwitch, HIGH);
           digitalWrite(recModuleSwitch, LOW);
           digitalWrite(whiteLed, LOW);

           audioVal = analogRead(audioIn);

           if (audioVal <= 14) {                                    // Flash lights to music
             digitalWrite(rgbLed, LOW);
           } else {
             digitalWrite(rgbLed, HIGH);
           }

           allStandingCheck();

           if (allStanding == 0)  {
             currentState = sActivate;
           }
           if (digitalRead(activateSwitch) == LOW) {
             currentState = sWaiting;
           }
           break;

       default:
           Serial.println("ERROR: default state");
           currentState = sWaiting;
           nextState = sActivate;
           break;
   }
}

//------------------- PIR SENSOR MOTION CHECK -------------------//
void motionCheck()  {
  for (int j=0; j < 5; j++)  {
    if (digitalRead(pirSensor) == LOW)  {
      motionCount++;
      delay(500);
    }
  }
}

//----------------- EVERYONE SITTING DOWN CHECK -----------------//
void allSittingCheck()  {
  if (digitalRead(seat1) == HIGH and digitalRead(seat2) == HIGH and
      digitalRead(seat3) == HIGH and digitalRead(seat4) == HIGH and
      digitalRead(seat5) == HIGH) {
    allSitting = 1;
  } else  {
    allSitting = 0;
  }
}

//------------------- EVERYONE STANDING STANDING ----------------//
void allStandingCheck()  {
  if (digitalRead(seat1) == LOW and digitalRead(seat2) == LOW and
      digitalRead(seat3) == LOW and digitalRead(seat4) == LOW and
      digitalRead(seat5) == LOW) {
    allStanding = 1;
    Serial.println("All Standing");
  } else  {
    allStanding = 0;
  }
}

Overall, we were very satisfied with how the project turned out. It was well received at the Meeting of the Minds, and we even won a prize from the STUDIO for Creative Inquiry. We plan on continuing to develop Boomboxes as concept, further improving the design and functionality of the space. The next public forum in which we are hoping to present the project is the Outdoor Lounge Exhibition of Artscape 2008, in Baltimore, MD, which we are currently on the waitlist for.

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.

Blog at WordPress.com.