Tentacle-box, mobile musicstation with beatsynched lights.

kabinett

Since I don’t get enough gigs, or any at all, I though I’d make a sound-system so I could go wherever and play a little show. So I decided to build a sound system that was moderately movable and would work of the grid.

Features:
So a featureset that I though was the least I could work with was this: It should be able to work without being connected to an outlet. It should have lights and it shouldn’t be to heavy to move around. Ateast not by a small wagon. And it should be loud. Not Mötorhead loud but loud enough. It should also be cheap enough so that I would not cry if it got trashed or stolen after a few gigs/parties.

2009-07-11 17.18.41

Materials:
So what do I need to get this together? some sort of battery, and a way to charge it. Luckily there are these car-starters charger thingys that you should use as help of your car battery dies. I bought one of those. Then a car-stereo I found. One that takes memory cards and USB-sticks and has a line in on the front. To control the lights I needed an Arduino, a few LED’s for the lights (I bought 200) and some sort of measuring the beat so that the lights could be synced to the tempo of the songs. I thought I could use a piezo and do the Arduino knock example, but later experimentation showed that I had to settle for a button-based solution.

2009-07-11 12.58.43

The build:
A box takes time to build, and woodworking is not my passion. So I went and gotten a box. It used to house a philips radio, way back when you did not have any TV’s. There was mirrors and everything in that box. but the back was just paper so I had to reinforce it. I mounted the speakers there and also the LED’s. I arranged the LED’s in groups to enhance the amount of light. Half of them are blue and half are white. The LED obscuring part did not work as I thought it should, But the results was OK anyways. As for the tentacle-painting. I don’t know. I like tentacles, not in a Hentai/Manga way, but just the cartoonish style of them.

The Arduino code:
The code is pretty basic. It multiplexes the led’s so that I did not have to add a shift registers. It also reads a button so that I can sync the lights by tapping. the code is pretty self-explanatory.

//tempo variables
byte tempo=120;  /* bmp of our sequence */
long rememberMillis=0;
long timeChange=250; /*a variable for calculating how long we are going to wait*/

//The light's stuff
int ledColWhteAndBlueRing[8] = {
 6,9,3,5,2,4,10,8 }; //these are the blue led's in order. Why no pin7? why not in order? Lazy at the wrong time I guess
int ledColSmall[8] = {
 3,2,9,6,4,8,10,5 };

// tap button
#define tapButton 14
byte tapButtonState;
byte lastTapButtonState = LOW;
long tapOldTime =0;
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
boolean justPressed = false;

byte currentLamp=0;
#define lampChange 100
int lampCounter=0;

float ix=0.0;
float ib=0.0;
float is=0.0;

float ixSpeed=1.0/4.0;
float ibSpeed=1.0/4.0;
float iySpeed=1.0/4.0;

int lampFrame[3][8]=
{
 {    1,0,1,0,1,0,1,0      }
 ,
 {    0,1,0,1,0,1,0,1      }
 ,
 {    0,0,0,0,0,0,0,0      }
};

void setup()
{

 pinMode(11, OUTPUT);
 pinMode(12, OUTPUT);
 pinMode(13, OUTPUT);

 digitalWrite(11,HIGH);
 digitalWrite(12,HIGH);
 digitalWrite(13,HIGH); 

 pinMode(tapButton,INPUT);
 /*starting the builtin pullup-resistor!*/
 digitalWrite(tapButton,HIGH);

 for (int i=0; i<8;i++)
 pinMode(ledColWhteAndBlueRing[i], OUTPUT);

 /*calculating the timeChange variable. milliseconds divided by
 tempo and 16th note, or something like that. I dont remember*/
 timeChange=((60000/tempo)/8);

 rememberMillis = millis();

}

void workSmall()
{
 digitalWrite(11,LOW); 

 for (int i=0; i<8;i++)
 if(lampFrame[2][i]==1)
 digitalWrite(ledColSmall[i], HIGH);   // set the LED on
 else
 digitalWrite(ledColSmall[i], LOW);   // set the LED on
 delay(1);

 digitalWrite(11,HIGH); 

}

void workWhite()
{
 digitalWrite(13,LOW); //White

 for (int i=0; i<8;i++)
 if(lampFrame[1][i]==1)
 digitalWrite(ledColWhteAndBlueRing[i], HIGH);   // set the LED on
 else
 digitalWrite(ledColWhteAndBlueRing[i], LOW);   // set the LED on
 delay(1);
 digitalWrite(13,HIGH); //White
}

void workBlue()
{
 digitalWrite(12,LOW); //Blue

 for (int i=0; i<8;i++)
 if(lampFrame[0][i]==1)
 digitalWrite(ledColWhteAndBlueRing[i], HIGH);   // set the LED on
 else
 digitalWrite(ledColWhteAndBlueRing[i], LOW);   // set the LED on
 delay(1);
 digitalWrite(12,HIGH); //Blue
}

void moveLamps1()
{
 for (int i=0; i<8;i++)
 {
 lampFrame[0][i]=0;
 lampFrame[1][i]=0;
 lampFrame[2][i]=0;
 }
 lampFrame[0][int(ix)]=1;
 lampFrame[1][int(ib)]=1;
 lampFrame[2][int(is)]=1;

 ix+=(ixSpeed);
 if (ix>8)
 ix=0;

 ib+=(ibSpeed);
 if (ib>8)
 ib=0;

 is+=(iySpeed);
 if (is>8)
 is=0;
}

void moveLamps2()
{

 for (int i=0; i<8;i++)
 {
 if (int(ix)==1)
 lampFrame[0][i]=0;
 else
 lampFrame[0][i]=1;

 if (int(is)==1)
 lampFrame[1][i]=0;
 else
 lampFrame[1][i]=1;

 if (int(ib)==1)
 lampFrame[2][i]=0;
 else
 lampFrame[2][i]=1;
 }

 ix+=(ixSpeed);
 if (ix>2)
 ix=0;

 is+=(iySpeed);
 if (is>2)
 is=0;

 ib+=(ibSpeed);
 if (ib>2)
 ib=0;
}

void moveLamps3()
{
 for (int i=0; i<8;i++)
 {
 lampFrame[0][i]=0;
 lampFrame[1][i]=0;
 lampFrame[2][i]=0;
 }

 lampFrame[0][int(ix)]=1;
 lampFrame[1][int(ib)]=1;
 lampFrame[2][int(is)]=1;

 ix-=(ixSpeed);
 if ((int)(ix)<0)
 ix=7;

 ib-=(ibSpeed);
 if ((int)(ib)<0)
 ib=7;

 is-=(iySpeed);
 if ((int)(is)<0)
 is=7;
}

void checkButtons()
{
 int reading = digitalRead(tapButton);
 if (reading != lastTapButtonState)
 {
 lastDebounceTime = millis();
 }
 if ((millis() - lastDebounceTime) > debounceDelay)
 {
 tapButtonState = reading;
 if(tapButtonState==true && justPressed==false)
 {
 //this is the most basic tempo calculation I could think of
 justPressed=true;
 timeChange= (millis()-tapOldTime)/8;
 tapOldTime=millis();
 }
 else if (tapButtonState == false)
 {
 justPressed=false;
 }
 }
 lastTapButtonState = reading;
}

void randomizelampSpeed()
{
 ix=(rand()%4)+2;
 is=(rand()%4)+2;
 ib=(rand()%4)+2;
 ixSpeed=1.0/((rand()%6)+2);
 ibSpeed=1.0/((rand()%6)+2);
 iySpeed=1.0/((rand()%6)+2);
}
/*our main baby */

void loop()
{

 workSmall();
 workWhite();
 workBlue();

 if( (millis()-rememberMillis) > (timeChange)) //this is one
 {
 rememberMillis=millis();

 switch(currentLamp)
 {
 case 0:
 moveLamps2();
 break;
 case 1:
 moveLamps1();
 break;
 case 2:
 moveLamps3();
 break;
 default:
 break;
 }
 lampCounter++;
 if (lampCounter >= lampChange)
 {
 currentLamp = rand()%3;
 lampCounter =0;
 randomizelampSpeed();
 }
 }
 checkButtons();
}

8 thoughts on “Tentacle-box, mobile musicstation with beatsynched lights.

  1. Hey I just found it at Make Magazine.
    Cool, thanks for sharing the code. What about the LED driver electronics? what external HW are you using besides the arduino?

  2. Pingback: Tentacle-box, 17 Amazing Ableton Live Tutorials, Z-DSP Experiments, Pluto, Pseudo scratching In Ableton Live 8, Free Yamaha DD-8 Samples, Sonic Fabric Neckties

  3. Pingback: Tentacle-box: A mobile music station with beat-synched lights | Diy all the Way

  4. Hi Joseph,

    The hardware is pretty easy, the button is just attached to analog in 0 and 5v.

    11,12 and 13 are used as ground then 2 to 10 are output to the LED’s.

  5. Well more then 8 actually. Perhaps I’m doing something wrong and either the LED’s or the Arduino wont last as long as it should but I think it probably will anyway.

  6. Pingback: Tentacle-box: A mobile music station with beat-synched lights | SquareCows

  7. Link exchange is nothing else except it is just placing the other person’s web site link on your page at proper place and other person will also do same in favor of you.|

Leave a Reply