Let's Make Robots!

Fiberoptic Wedding Reception Table Centerpieces

Fades between wedding colors and gets collected by kids

The wedding(s) actually took place last year (3/1 and 9/7 respectively, the first being the official "on paper" rushed ceremony to get me on my wife's insurance and the second falling on the originally planned date and celebrated with guests and a reception) but Oss encouraged me to share this project when he was doing something similar with rgb LEDs.  I made 15 of these for the tables at the reception.  We got the bodies with the fiberoptic sprays off eBay.  They had built-in battery compartments (3xAA, which I filled with "heavy duty" cheap-os but which still apparently ran these things for three weeks continuously) but they were green plastic, so I had to spray paint them with Testors modeling paint.  We chose chrome.  Also, they did a lightshow that wasn't what we wanted from the factory.

The idea was to fade between the three wedding colors (Tiffany blue(thus "Moon River" in the video), Pony-boy tan and Clara Belle brown, the last two being the colors of two of our dogs) using Photoshop's RGB interpretation of those colors for PWM values.  It took a little tweaking to get it even close.  Also, astute makers will note that the ATTiny only has PWM on two pins native.  I had to cheat the third channel to get a decent fade.  It would have been nice to make use of more of the OEM electronics, but they were all SMD slagged, so I could hardly even get the LEDs off.  Besides, I wanted an excuse to order some components that wouldn't seem like a completely selfish affair.

The electronics I put on cut up chunks of RadioShack perfboards.  They ended up looking kind of like this:

...plus an IC, of course.  I just wired the +/- lines from the battery compartments into pins 8 and 4 respectively (on this photo, Pin 1 would be lower right.)  Only Pins 0 and 1 (DIP pins 5 and 6, top left) are PWM on the Tiny 45/85, so pin 2 (DIP 7) was the cheated PWM.  I didn't even bother to put a power switch in-I just cut little pieces of plastic gel and put them between one battery terminal and the compartment connector, then had the hired help pull them out when they set up the tables.  Worked like a charm.

The code is for Arduino as ISP (see High Low Tech) and it may seem like a lot-120 some lines-for such a small, simple result, but I am really only sharing this so others can learn from it as an example or for similar-but-different projects (not because I think other robot-makers want to duplicate the project.)  I think the commenting is pretty complete:

#define redPin 0//0 on ATTiny DIP 5
#define greenPin 2//2 on ATTiny DIP 7
#define bluePin 1//1 on ATTiny, DIP6 may switch blue and red depending on pin layout of LEDs
int r1,r2,rt,g1,g2,gt,b1,b2,bt;//1st and 2nd values and transition adder
//photoshop values:Pony:246,189,229 Clara:134,80,27 Tiffany:219, 245, 243
//real values: Pony:195,230,195 Clara:33,35,27 Tiffany:75,245,243
int qSpeed = 1;//delay for softPWM
void setup(){
  pinMode (redPin, OUTPUT);
  pinMode (greenPin, OUTPUT);
  pinMode (bluePin, OUTPUT);
}

void loop(){
  pony2Clara();
  clara2Tifany();
  tiffany2Pony();


}

void pony2Clara(){//pony
  rt=255;
  gt=230;
  bt=0;
  analogWrite (redPin,rt);
  //softPWM(greenPin, gt, qSpeed);
  digitalWrite(greenPin, HIGH);
  analogWrite (bluePin,bt);
  delay (8000);
  //first transition, down r162g195b168
  //at ten steps, r=16, g=19, b=17
  for (int i; i<10;i++){
    rt=rt-16;
    gt=gt-19;
    bt=bt-17;
    analogWrite (redPin,rt);
    softPWM(greenPin, gt, qSpeed);
    analogWrite (bluePin,bt);
    delay(20);
  }//clara
  rt=2;
  gt=50;
  bt=0;
  analogWrite (redPin,rt);
  softPWM(greenPin, gt, qSpeed);
  analogWrite (bluePin,bt);
  delay (8000);
}

void tiffany2Pony(){//pony
  //first transition, down r162g195b168
  //at ten steps, r=16, g=19, b=17
  //tiffany
  rt=0;
  gt=50;
  bt=100;
  analogWrite (redPin,rt);
  //softPWM(greenPin, gt, qSpeed);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
  //analogWrite (bluePin,bt);
  delay (7000);
  //second transition, up,down,down r120g15b50
  //at ten steps, r=4, g=21, b=22
  for (int k; k<10;k++){
    rt=rt+15;
    gt=gt+20;
    bt=bt-10;
    analogWrite (redPin,rt);
    softPWM(greenPin, gt, qSpeed);
    analogWrite (bluePin,bt);
    delay(10);
  }
  rt=255;
  gt=255;
  bt=0;
  analogWrite (redPin,rt);
  digitalWrite(greenPin, HIGH);
  //softPWM(greenPin, gt, qSpeed);
  analogWrite (bluePin,bt);
  delay (10);
}

void clara2Tifany(){//clara
  rt=25;
  gt=50;
  bt=27;
  analogWrite (redPin,rt);
  softPWM(greenPin, gt, qSpeed);
  analogWrite (bluePin,bt);
  delay (10);
  //second transition, up r42g210b226
  //at ten steps, r=4, g=21, b=22
  for (int j; j<10;j++){
    rt=rt+4;
    gt=gt+15;
    bt=bt+20;
    analogWrite (redPin,rt);  
    softPWM(greenPin, gt, qSpeed);
    analogWrite (bluePin,bt);
    delay(20);
  }//tiffany
  rt=40;
  gt=50;
  bt=243;
  analogWrite (redPin,rt);
  softPWM(greenPin, gt, qSpeed);
  analogWrite (bluePin,bt);
  delay (100);
}

void softPWM(int pin, int freq, int sp) { // software PWM function that fakes analog output
  digitalWrite(pin,HIGH); //on
  delayMicroseconds(sp*freq);
  digitalWrite(pin,LOW); //off
  delayMicroseconds(sp*(255-freq));
}

The softPWM function is a pretty standard method.  You see it and variations on it in everything from this kind of LED fading to manual servo control.  It would have been just as easy to call softPWM on all three pins for each transition, but I had already written the analogWrites in when I realized I was a PWM short so why retype everything?

One thing you'll notice is that the pause at full brightness isn't consistent from function to function-pony2clara contains the pauses for both Pony and Clara's colors.  If I remember right I did this because of the way I had to cheat the softPWM, but it's been like 8 months since I coded this.  I don't know why it ended up that way anymore.  I just know it didn't work when I tried to do it with the functions mirrored.  (It would be nice if Arduino let you do class construction in the main sketch, but that wouldn't have helped me here apparently.)

Sorry it took me so long to put this up.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Good comments max! And right on time \o/

Thanks Max, nice project and I truly appreciate the comments in code, going to try and useand  learn from this for hoff''s lmr bling medallion.