Blinky Lights Software

1 view
Skip to first unread message

Scott

unread,
Dec 13, 2010, 2:25:41 PM12/13/10
to Columbia Gadget Works
I have a processing script and an arduino script that will blink 8
channels of lights. Needs a lot of tuning, and no zero detect
interrupt yet. But I wanted to get this out in the wild. I will figure
out how to post.

Scott.K...@gmail.com

unread,
Dec 13, 2010, 2:30:18 PM12/13/10
to columbia-g...@googlegroups.com
MusicalBlinkyLights.pde(2) is the arduino script. MusicalBlinkyLights.pde is the Processing script. They are both on the files page. I can't seem to upload the mp3 of Funky Kingston I was using. Just put an mp3 in the data directory of the Processing script, and change the file name in the code.

Scott

unread,
Dec 18, 2010, 4:50:51 PM12/18/10
to Columbia Gadget Works
Anyone still out there? Anything going on with BlinkyLights?

On Dec 13, 1:30 pm, Scott.Kovale...@gmail.com wrote:
> MusicalBlinkyLights.pde(2) is the arduino script. MusicalBlinkyLights.pde  
> is the Processing script. They are both on the files page. I can't seem to  
> upload the mp3 of Funky Kingston I was using. Just put an mp3 in the data  
> directory of the Processing script, and change the file name in the code.
>

Scott.K...@gmail.com

unread,
Dec 18, 2010, 6:17:20 PM12/18/10
to columbia-g...@googlegroups.com
FYI, programming light blinking in an automated and intelligent way != trivial.

Scott

unread,
Dec 18, 2010, 7:05:27 PM12/18/10
to Columbia Gadget Works
Now this here works purty good. I try to post a video tonight.

/**
* MusicalBlinkyLights
* by Scott Kovaleski
*
* Make an mp3 player and analyzer to blink some strings of lights.
*/

import processing.serial.*;
import ddf.minim.analysis.*;
import ddf.minim.*;

Serial myPort; // Create a Serial port object
AudioPlayer player; // Create an audio player object
Minim minim; // This one has the FFT stuff in it
FFT fft; // FFT object
BeatDetect beat;
BeatListener bl;

String windowName;
int nChannel = 1; // number of lighting channels for magnitude info
String outString; // string of 1s and 0s to send to the Arduino

void setup()
{
size(512, 200, P2D); // sets up a window

minim = new Minim(this); // set up a Minim object

// load a file, give the AudioPlayer buffers that are 1024 samples
long
// player = minim.loadFile("groove.mp3");

// load a file, give the AudioPlayer buffers that are 2048 samples
long
player = minim.loadFile("FunkyKingston.mp3", 2048);
player.loop(); // play the file on a loop
//player.play(); // play the file one time through

// create an FFT object that has a time-domain buffer the same size
as player's sample buffer
// note that this needs to be a power of two and that it means the
size of the spectrum
// will be 512. see the online tutorial for more info.
fft = new FFT(player.bufferSize(), player.sampleRate());
fft.linAverages(nChannel); // do nchannel averages over the
spectrum
textFont(createFont("SanSerif", 12));
windowName = "None";

// a beat detection object that is FREQ_ENERGY mode that
// expects buffers the length of song's buffer size
// and samples captured at songs's sample rate
beat = new BeatDetect(player.bufferSize(), player.sampleRate());
// set the sensitivity to 300 milliseconds
// After a beat has been detected, the algorithm will wait for 300
milliseconds
// before allowing another beat to be reported. You can use this to
dampen the
// algorithm if it is giving too many false-positives. The default
value is 10,
// which is essentially no damping. If you try to set the
sensitivity to a negative value,
// an error will be reported and it will be set to 10 instead.
beat.setSensitivity(100);
// make a new beat listener, so that we won't miss any buffers for
the analysis
bl = new BeatListener(beat, player);

// I know that the first port in the serial list on my mac
// is usually my Arduino, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
String portName = Serial.list()[0];
println(portName);
myPort = new Serial(this, portName, 9600);
}

void draw()
{
background(0); // black window background
stroke(255); // white lines on the window

// draw the waveforms
// the values returned by left.get() and right.get() will be between
-1 and 1,
// so we need to scale them up to see the waveform
// note that if the file is MONO, left.get() and right.get() will
return the same value
for(int i = 0; i < player.left.size()-1; i++)
{
line(i, 50 + player.left.get(i)*50, i+1, 50 + player.left.get(i
+1)*50);
line(i, 150 + player.right.get(i)*50, i+1, 150 + player.right.get(i
+1)*50);
}

// perform a forward FFT on the samples in player's left buffer
// note that if player were a MONO file, this would be the same as
using player.right or player.left
fft.forward(player.mix);
for(int i = 0; i < fft.specSize(); i++)
{
// draw the line for frequency band i, scaling it by 4 so we can
see it a bit better
line(i, height, i, height - fft.getBand(i)*4);
}
fill(255);
// keep us informed about the window being used
text("The window being used is: " + windowName, 5, 20);

/* Here is one way to do this
// average fft info into bands and send it to the microcontroller to
switch on the lights
for (int i=0; i < fft.avgSize(); i++) {
// stores the on or off info in binary form in outstring. A string
// of 8-1s and 0s for ons and offs
if (fft.getAvg(i) > 1) outString += 1;
else outString += 0;
}
*/

/* Here is another way to do this
// Using the lowest band average, turn on the lights
int num = int(fft.getAvg(0));
if (num > nChannel) num = nChannel;
for (int i=0; i<num; i++) outString += 1;
if (num < nChannel) for (int i=num; i<nChannel; i++) outString += 0;
*/

// Using the lowest band average, turn on the lights
int num = int(fft.getAvg(0));
if (num > 2) num = 2;
for (int i=0; i<num; i++) outString += 1;
if (num < 2) for (int i=num; i<2; i++) outString += 0;

if (beat.isKick()) {
outString += 1;
outString += 1;
} else {
outString += 0;
outString += 0;
}
if (beat.isSnare()) {
outString += 1;
outString += 1;
} else {
outString += 0;
outString += 0;
}
if (beat.isHat()) {
outString += 1;
outString += 1;
} else {
outString += 0;
outString += 0;
}

// Write it out to the Arduino
myPort.write(outString);
print(outString+", ");
println(fft.getAvg(0));

// Clear outstring and wait a little to improve serial coms. This
part sucks, makes sync less good.
outString="";
delay(200);
}

void keyReleased()
{
if ( key == 'w' )
{
// a Hamming window can be used to shape the sample buffer that is
passed to the FFT
// this can reduce the amount of noise in the spectrum
fft.window(FFT.HAMMING);
windowName = "Hamming";
}

if ( key == 'e' )
{
fft.window(FFT.NONE);
windowName = "None";
}
}

void stop()
{
// always close Minim audio classes when you are done with them
player.close();
minim.stop();

super.stop();
}

class BeatListener implements AudioListener
{
private BeatDetect beat;
private AudioPlayer source;

BeatListener(BeatDetect beat, AudioPlayer source)
{
this.source = source;
this.source.addListener(this);
this.beat = beat;
}

void samples(float[] samps)
{
beat.detect(source.mix);
}

void samples(float[] sampsL, float[] sampsR)
{
beat.detect(source.mix);
}


On Dec 18, 5:17 pm, Scott.Kovale...@gmail.com wrote:
> FYI, programming light blinking in an automated and intelligent way !=  
> trivial.
>

Scott

unread,
Dec 18, 2010, 7:23:38 PM12/18/10
to Columbia Gadget Works
That was Processing.org code, FYI.

On Dec 18, 5:17 pm, Scott.Kovale...@gmail.com wrote:
> FYI, programming light blinking in an automated and intelligent way !=  
> trivial.
>

Scott

unread,
Dec 18, 2010, 8:53:06 PM12/18/10
to Columbia Gadget Works

Zach Zeman

unread,
Dec 19, 2010, 4:42:46 PM12/19/10
to columbia-g...@googlegroups.com
Sorry for the email silence. I'm not sure if you heard, but we had to abandon the board we made at the hack night because we were unable to get one of the channels working. I'm pretty sure that bummed the hardware folk out a little bit. Also, the holidays have slammed me much more than expected (I don't even have kids, how does this happen?), and I just have not felt up to keeping up with email.

But this email is not about excuses. It's about a celebration of Scott's successful prototype.

The video actually looks really cool. I can see that being very eye-catching with a more active song. I've only glanced over the source code you sent out, but I may try to make this work with the 5-channel craptastic relay board that I made last year tonight or tomorrow night. Unfortunately, I don't think that there will be enough interest for a hack night this week, and next week will probably be difficult, too. If I get some full-scale lights flashing, though, I can guarantee a video response.

No matter what, we can consider this all prep work for the totally kick-ass light display that we will be putting up on our hackerspace around this time next year. And if it was trivial, it wouldn't be near as fun. I'm just sorry Scott has been doing so much of the work while in comms blackout.

Thanks.

-Zach

Nathan Odle

unread,
Dec 20, 2010, 5:42:08 PM12/20/10
to columbia-g...@googlegroups.com
Yeah, I was excited to hopefully come out with a new board, all fixed up, but the holidays are busy and I just didn't have time to get it done.  Next time, maybe we can start waaay earlier on any holiday-themed projects :)

Since you mention hackerspace...  I may have something on that for us.  As in, something awesome.  But it's a 'maybe' at the moment, so I don't want to discuss too much on the public forum.

James Durham

unread,
Dec 20, 2010, 7:13:53 PM12/20/10
to Columbia Gadget Works
Hey good work Scott. I was about to shoot myself with FFT learning
curve. Although, I probably can give a good presentation now on FFT,
and the bits and pieces of software dev issues.

Scott Kovaleski

unread,
Dec 20, 2010, 7:35:50 PM12/20/10
to columbia-g...@googlegroups.com
Since when do awesome music driven light shows only happen in December? Cuz I am pretty sure nobody told Pink Floyd about that rule.

I think we could try to organize a "rent party" or something soon (say by mid-February) and develop a light show for that. It could be something much more bigger, too. Lasers. I've seen cool stuff done with computer projectors and smoke machines. And blinky lights.

Besides, I have (finally) been having some fun with my Arduino, and I am not ready to admit defeat! (Although serial connection speeds suck, and doing intelligent audio analysis is much tougher than I first expected).

Sooo, everybody get to work! Think up something cool. Work alone or in teams. Post your videos here and on the Facebook page. You are hackers for chissakes! Find the Jolt Cola and Cheetos, put on your finest battle sweatpants, put the soundtrack to Wargames on your vacuum tube driven steampunk Star Trek themed turn table, and get crackalackin'!

Dr. Scott Kovaleski

Associate Professor
Electrical and Computer Engineering
University of Missouri
349 Engineering Building West
Columbia, MO 65211

ian

unread,
Dec 21, 2010, 2:08:11 PM12/21/10
to Columbia Gadget Works
party sounds awesome!

as for the code -- I went ahead and set us up with a CGW group on
github to put our code in

anyone with github accounts should contact me so I can add them to the
group

our github page is:
https://github.com/CGW

the first repo contains that code that Scott shot out to the list

unfortunately it's missing some stuff -- I'm assuming Scott you just
ripped it from somewhere over on here? http://code.google.com/p/processing/
??

I'll look around later on today and see if I can't find where you got
it from and re-implement so we can start hacking it out

then I'll go ahead and make some basic specs

sorry, I've been away for a bit -- things are starting to blow up for
my business

- Ian

On Dec 20, 6:35 pm, Scott Kovaleski <scott.kovale...@gmail.com> wrote:
> Since when do awesome music driven light shows only happen in December? Cuz I am pretty sure nobody told Pink Floyd about that rule.
>
> I think we could try to organize a "rent party" or something soon (say by mid-February) and develop a light show for that. It could be something much more bigger, too. Lasers. I've seen cool stuff done with computer projectors and smoke machines. And blinky lights.
>
> Besides, I have (finally) been having some fun with my Arduino, and I am not ready to admit defeat! (Although serial connection speeds suck, and doing intelligent audio analysis is much tougher than I first expected).
>
> Sooo, everybody get to work! Think up something cool. Work alone or in teams. Post your videos here and on the Facebook page. You are hackers for chissakes! Find the Jolt Cola and Cheetos, put on your finest battle sweatpants, put the soundtrack to Wargames on your vacuum tube driven steampunk Star Trek themed turn table, and get crackalackin'!
>
> Dr. Scott Kovaleski
>
> Associate Professor
> Electrical and Computer Engineering
> University of Missouri
> 349 Engineering Building West
> Columbia, MO 65211
>
> P: 573-882-8377
> F: 573-882-0397
>
> On Dec 20, 2010, at 4:42 PM, Nathan Odle <nathan.o...@gmail.com> wrote:
>
>
>
> > Yeah, I was excited to hopefully come out with a new board, all fixed up, but the holidays are busy and I just didn't have time to get it done.  Next time, maybe we can start waaay earlier on any holiday-themed projects :)
>
> > Since you mention hackerspace...  I may have something on that for us.  As in, something awesome.  But it's a 'maybe' at the moment, so I don't want to discuss too much on the public forum.
>
> > On Sun, Dec 19, 2010 at 3:42 PM, Zach Zeman <gamerdon...@gmail.com> wrote:
> > Sorry for the email silence. I'm not sure if you heard, but we had to abandon the board we made at the hack night because we were unable to get one of the channels working. I'm pretty sure that bummed the hardware folk out a little bit. Also, the holidays have slammed me much more than expected (I don't even have kids, how does this happen?), and I just have not felt up to keeping up with email.
>
> > But this email is not about excuses. It's about a celebration of Scott's successful prototype.
>
> > The video actually looks really cool. I can see that being very eye-catching with a more active song. I've only glanced over the source code you sent out, but I may try to make this work with the 5-channel craptastic relay board that I made last year tonight or tomorrow night. Unfortunately, I don't think that there will be enough interest for a hack night this week, and next week will probably be difficult, too. If I get some full-scale lights flashing, though, I can guarantee a video response.
>
> > No matter what, we can consider this all prep work for the totally kick-ass light display that we will be putting up on our hackerspace around this time next year. And if it was trivial, it wouldn't be near as fun. I'm just sorry Scott has been doing so much of the work while in comms blackout.
>
> > Thanks.
>
> > -Zach
>

ian

unread,
Dec 21, 2010, 4:31:37 PM12/21/10
to Columbia Gadget Works
also, not quite sure how to set the gravatar to the correct logo --
think I need someone w/a @columbiagadgetworks.com address or something
-- I forgot mine :)

On Dec 21, 1:08 pm, ian <i...@airodig.com> wrote:
> party sounds awesome!
>
> as for the code -- I went ahead and set us up with a CGW group on
> github to put our code in
>
> anyone with github accounts should contact me so I can add them to the
> group
>
> our github page is:https://github.com/CGW
>
> the first repo contains that code that Scott shot out to the list
>
> unfortunately it's missing some stuff -- I'm assuming Scott you just
> ripped it from somewhere over on here?http://code.google.com/p/processing/

Chad LaFarge

unread,
Dec 27, 2010, 2:44:05 PM12/27/10
to Columbia Gadget Works
How fast and quiet are the Relays you guys have chosen for the Blinky Lights?  Has anyone shopped around for the most silent and responsive (read: low-latency) relays? If so, please... do tell :)
 
Thank you.
 
Chad

plasmator

unread,
Dec 30, 2010, 10:14:53 AM12/30/10
to Columbia Gadget Works
From the relay data sheets that Zach gave me to work on the board,
they look like standard telecomm relays. As far as mechanical relays
go, those made for telecomm are pretty posh if they come from a
reputable source. They are pretty quick and quiet, but on the flip
side they don't handle much current, either.

If low-latency is what you're after though, you want a solid-state
solution. This ranges from a simple little transistor for small DC
loads, up to big solid state relays for larger AC loads. With AC, you
do need to be careful with inductive loads of course. Diodes and zero-
crossing detection are the order of the day.

For a good tutorial on switching devices, check out this page from
National Instruments:
http://zone.ni.com/devzone/cda/tut/p/id/2774

Also, if Mark Rages wants to chime in, he's forgotten way more than
the rest of us probably know about this stuff.
> > > > > > out how to post.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages