ink heater the beginnings of a blog

Beverage cabinet update!

Our interactive beverage cabinet is coming along... slowly! Alex and I have been working on the Arduino code for the past ten days or so, but we've hit a number of obstacles along the way and are still working through the kinks.

The cabinet has five switches, one in each compartment. When a bottle is removed, a switch is flipped in that compartment, triggering a music track and light sequence corresponding to that bottle.

Initially, we figured that the code would be relatively straightforward - it's just five switches, a few lights and some tunes, right? Well, yes, but using multiple switches to control multiple light sequences through the MIDI dimmer was a little trickier than anticipated.

Our first step was getting the MIDI dimmer to communicate with the Arduino. We tested this using Rory Nugent's test code.

Next, we programmed the dimmer to begin the light sequence when a switch is turned on, and stop the sequence then the switch is turned off, without delays (which cause problems as the Arduino stops).

When we tested the code using the lightGo() and lightHalt() functions, the light turned on as hoped when the switch is pressed, but didn't begin the incremental dimming up & down.

So, we sought advice and learned that the parts of code involving (switchState ! == lastSwitchState) and if (millis() - previousMillis > interval) were the source of our issues. So, we added arrays for brightness values, switchState, lastSwitchState, previousMillis and interval variables for each switch, ending up with the following code:

MIDI Dimmer code

int midiPin = 1;   //  digital output pin for the midi dimmer
int lastSwitchState[5]; // previous state of the switch
int lightToggle[5]; //DOES THIS NEED TO BE AN ARRAY? Variable for toggling the light at max and min values
int switchState[5];         // current state of each switch
int lastswitchState[5];     // previous state of each switch
int previousMillis[5];      //DOES THIS NEED TO BE LONG?
int brightness[5];          // array of brightnesses for each light
int switchPins[] = {
2,3,4,5,6};  // digital input array to hold the switch pin numbers

// brightness goes from 1-127...not sure what goes in the curly brackets below
//int brightness[] = { ? }

void setup() {
for (int thisChannel = 0; thisChannel < 5; thisChannel++) {
//initialize switch pins as inputs
pinMode(switchPins[thisChannel], INPUT);
pinMode(midiPin, OUTPUT); //initialize midi dimmer as output
Serial.begin(31250); // set MIDI baud rate
}
}

void loop() {
for (int thisChannel = 0; thisChannel < 5; thisChannel++){
// read the switch:
switchState[thisChannel] = digitalRead(switchPins[thisChannel]);
//if the switch has changed,
// compare the switchState to its previous state
if (switchState[thisChannel] != lastswitchState[thisChannel]) {
// if the switch has changed from off to on:
if (switchState[thisChannel] == HIGH) {
// if the current state is HIGH then the switch
// went from off to on:
lightGo(thisChannel, 10); //REPLACE 10 with "interval"
}
else {  // else the switch changed, going from on to off:
lightGo(thisChannel, 3); //REPLACE 10 with "interval"
}
// save the current state as the last state,
//for next time through the loop
lastswitchState[thisChannel] = switchState[thisChannel];
}
else {  // else the switch didn't change.
// dim all the light channels:
brightness[thisChannel]--;
lightGo(brightness[thisChannel], 30);

}
}

//if the switch is off:
if (switchState == LOW) {
//call the lightHalt function
lightHalt (0);
//lightHalt (1);
//lightHalt (2);
}
*/
}

// data1 should be from 0-5, and tells the dimmer which light group
// data2 should be from 0-127 and represents the brightness
void noteOn(char cmd, char data1, char data2) {
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}

void lightGo (int thisChannel, long interval) { //
if ((millis() - previousMillis[thisChannel]) > interval) {
//if the light is on at all
if (brightness[thisChannel] == 127) {
lightToggle[thisChannel] = 0;
// Serial.println("here");
}
//if light is off
else if (brightness[thisChannel] == 0) {
lightToggle[thisChannel] = 1;
}

if (lightToggle[thisChannel]==1) {
brightness[thisChannel]++;
}
else {
brightness[thisChannel]--;
}
//turn on the light
noteOn(0x90, thisChannel, brightness[thisChannel]);
// save the last time you blinked the light
previousMillis[thisChannel] = millis();
}
}

void lightHalt(int thisChannel) {
//if the switch is off, turn off the light:
noteOn(0x90, thisChannel, 0);
//save the last time the light blinked:
previousMillis[thisChannel] = millis();
}

We're still working on figuring out and finishing this code and making it work. In the meantime, we've hard-coded everything in the hope of making it work.

MP3 Trigger
The MP3 Trigger allowed two ways for us to play MP3 files through Arduino: we could either use the 7 trigger pins on the board to directly trigger 7 pre-selected tracks, or use serial communication through Arduino to enable remote triggering of all tracks on the board, with the added advantage of volume control. We opted for the latter - however, the MIDI dimmer was already using the serial port, so we got the MP3 Trigger functioning through software serial.

We loaded our tracks onto the MP3 Trigger, and used the XX library to link the songs to specific switches.

Switches = Wicked Witches!
We tried out one switch to see if the music and lights would work together and after a bit of troubleshooting, it worked! However, when we tried the cabinet with more than one switch, everything went a bit crazy.

And that's where we are right now. We've worked our posteriors off, we've learned a TON, and we're pretty certain that we're almost there.

Images/video of our progress shall be forthcoming. But first, sleep. And breakfast.

Pcomp final: Interactive Liquor Cabinet

Over the past few weeks, Alex Vessels and I have brainstormed on the floor at ITP, in the East Village, Chinatown and everywhere in between to settle upon the perfect form factor for our party device. Somewhere along the way, we settled upon the perfect form factor for our party device: an interactive liquor cabinet that will create a different type of party mood, depending on which liquor is selected.

We're using an existing antique cabinet with five compartments, which will light up when the cabinet is opened. There will be one object placed in each compartment. When an item is removed from the cabinet, a song corresponding to that object will play, and a light sequence will kick in. For example, take out the bottle of Jameson, and you'll hear the Pogues and be dazzled by a green light display. Or select the Jim Beam, and you'll hear Guns 'n' Roses and be dazzled by red and blue flashing lights.

We're experimenting with building various types of switches to place on the shelves of the cabinet, and we're currently learning to use the MIDI dimmer from the ER to control AC lights. For now, we'll use the Processing Minim library and a laptop to control the music - eventually, we'll probably switch to aWave Shield, which can be hidden inside the cabinet (and eliminating the laptop from the equation).

Below is a photo of the cabinet as is. We're hoping to keep the exterior appearance intact and preserve the old-time aesthetic.

 

Cabinet with the door open

 

 

 

Instant party

Finals are upon us, and it's the most wonderful time of the year (almost). What better time to encourage stress-busting through partying? For the Pcomp final, I'm hoping to create a device that enables the user to get the party started, or at least host a 5-minute stress-busting mini party. The device should be portable, and possibly wearable, thus enabling the user to take, and start, the party anywhere.

Matt Ganucheau made the excellent suggestion of using this guy dancing on a hillside at the Sasquatch Festival as inspiration for the project. He dances around by himself for quite a while, another guy joins him after about 20 seconds, then another at 0:53, and around 1:10, a steady stream of others joins in. By the end of the three-minute clip, the lone dancer guy has created quite the dance party.

Watching the Sasquatch guy, we realized that a good way to tackle the potential annoying-ness of the device - for example, if used by the wrong hands, in the wrong social situation, or amidst an unwilling crowd - would be to adjust the party intensity depending on the amount of interaction/interest that the user receives upon activating the device. For instance, the music could become incrementally louder as others join in.

What are the essential ingredients to get everyone in the mood to party? Music, lights, disco ball, confetti and physical movement are some of the factors we'll explore in the next week or so...

Tagged as: No Comments
   

my posts

Categories

tag cloud??

android arduino art assistive technology breathing bronx zoo cabinet comics commlab communication computer vision eye tracking forster freshkills FSR games giraffes graphic arts graphics Hospitable Room images interactivity LEDs light midi Mobile Me(dia) museum Nature of Code park PComp physical computing public Rest of You sensor sensors servo spontaneous storytelling stupid sustainability swig & jig tree visitors