Thursday, April 29, 2010

The LEDs

In this episode, I'll talk a bit about how I set up the LED lighting in the pinball bells.















Here's the breadboard and arduino setup. I'll post the code for the arduino at the bottom of this post.

I used 3-color LEDs (RGB) and the pots acted as color mixers for each LED. Maybe you can tell from the board, but that means I could only have a maximum of 6 LEDs plugs in at any time.


















Testing the LEDs.

The wiring was a bit of a mess, and it was tricky sliding the wire wrap through the holes I drilled in the bells. It was also a pain sticking the wires in the breadboard every time I had a new setup... but hey, no one said being an artist was easy. Having the patience of an animator definitely came into play!


















Hiding the wires.

I drilled holes in the bottom of the set and had the breadboard hiding below.

On each frame, I twisted the pots for a new color for the flash lights effect.

















Paul Shin sets up a shot.

Here we tested the LEDs and got the framing right. We shot JPEGs on a Canon 5D.

The Christmas lights were plugged into a dimmer so I could fade the ambient lights down and create drama when a bell was hit by the pinball.


Now as promised, the code! Please credit Joe if you repost, he was essential to helping me set this up!

/*
LED control. 3 TLC5940s daisy chained.

6 pots are connected to Analog pins 0 - 5. Each pot controls 2 or 3
RGB LEDs connected to the TLC5940.

- joe saavedra april 2010
*/

#include "Tlc5940.h"

int pot[] = {0,1,2,3,4,5};
int currVal[] = {0,1,2,3,4,5};
/*
//this is laying out exactly which (set of three) pins each pot controls
// -- each set of three here will have the same color (assuming all are
// plugged in as R,G,B uniformly
int legSet1[] = {0,1,2, 18,19,20, 36,37,38};
int legSet2[] = {3,4,5, 21,22,23, 39,40,41};
int legSet3[] = {6,7,8, 24,25,26, 42,43,44};
int legSet4[] = {9,10,11, 27,28,29, 45,46,47};
int legSet5[] = {12,13,14, 30,31,32, 48,48,48}; //actually there are only 47 legs
int legSet6[] = {15,16,17, 33,34,35, 48,48,48}; //i am putting 48 as a filler so the
//arrays are all the same size.
*/

//---- SAME AS ABOVE, BUT NEATER, 2D array, easier to access ----
int legSet[6][9] ={ {0,1,2, 18,19,20, 36,37,38} , {3,4,5, 21,22,23, 39,40,41},
{6,7,8, 24,25,26, 42,43,44} , {9,10,11, 27,28,29, 45,46,47},
{12,13,14, 30,31,32, 48,48,48} , {15,16,17, 33,34,35, 48,48,48} };
//i am putting 48 as a filler so the arrays are all the same size.

//this was just for testing
int leg[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48};

void setup(){
//Serial.begin(9600);
Tlc.init();
}

void loop(){
//Tlc.clear();

for(int i = 0; i<6; j="0;"> 4000){
for (int j=0; j<9;> 10 && currVal[i] < j="0;" j="1;" mapped =" map(currVal[i]," j="2;"> 1350 && currVal[i] < j="0;" j="1;" j="2;" mapped =" map(currVal[i],"> 2600 && currVal[i] < 4000){
for (int j=0; j<9; j+=3){
int mapped = map(currVal[i], 2600, 4000, 0, 3095);
Tlc.set(legSet[i][j], mapped); //red getting added
}
for (int j=1; j<9; j+=3){
Tlc.set(legSet[i][j], 0); //green off
}
for (int j=2; j<9; j+=3){
Tlc.set(legSet[i][j], 4095); //blue on
}
Tlc.update();
}

/* //test to control all three legs identically
for (int j=0; j<9; j++){
Tlc.set(legSet[i][j], currVal[i]);
Tlc.update();
}
*/
}
}

Tlc.update();
}