Star Topper

This tree topper shows that the holiday season is always a good opportunity to practice one’s making skills.  Usually I’m focused on woodworking because cutting boards are always in style, but this season presents a new opportunity for learning.  Combining a number of skills and techniques to include CAD, 3D printing, soldering and some programming, this latest project kept me busy during the recent winter cold spell.

The first step was to make a create some sort of digital mockup of the tree topper idea.  I used Tinkercad to sketch up the design.

Once the design was complete, it was off to the 3D printer.  Thankfully, everything worked out nicely with the measurements and the parts fit together nicely.  I used glow-in-the-dark filament and printed at 20% infill.  This would ensure the the LEDs would be visible and perhaps the glow would last a little while after everything is powered off.

Now came the fun part: programming the microcontroller to display the animations.  I made sure to test the animations before installing all the hardware, so I wouldn’t be stuck trying to undo my handiwork should the programming not work out properly.  My idea was to have the LEDs display a few simple patterns, such as flashing in sequence, speeding up and slowing down, all looping indefinitely.  The LEDs would be controlled by a Trinket, Adafruit’s very small Arduino compatible microcontroller powered by an Atmel ATtiny85.  You can see the code I used at the bottom of this post.

With everything programmed and ready to install, the final step would be to wire and position the LEDs in the shell.  This was very challenging because of the tight space which I had to work in.  I didn’t want to have lots of wires, so I did all the soldering with parts in their final positions.  As a result, there wasn’t much wiggle room or space for lots of adjustments.

Here’s the final show.  I think it turned out great!

 

Here’s the code for the animation:

 /*
Star Topper
by Brent
*/

int led = 0; // LED 1 position
int led1 = 1; // LED 2 position
int led2 = 2; // LED 3 position
int led3 = 3; // LED 4 position
int led4 = 4; // LED 5 position
int count = 0; // Will use while loop for stepping through the animations
int factor = 200; // For use with the speed up and slow down trace effect

// the setup routine runs on reset:
void setup() {
 // initialize the digital pin as an output.
 pinMode(led, OUTPUT);
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(led4, OUTPUT);
}

// the whole loop runs forever:
void loop() {
 while(count < 10) {
 digitalWrite(led, HIGH); 
 delay(100);
 digitalWrite(led, LOW);
 delay(100);
 digitalWrite(led1, HIGH); 
 delay(100);
 digitalWrite(led1, LOW);
 delay(100);
 digitalWrite(led2, HIGH); 
 delay(100);
 digitalWrite(led2, LOW);
 delay(100);
 digitalWrite(led3, HIGH); 
 delay(100);
 digitalWrite(led3, LOW);
 delay(100);
 digitalWrite(led4, HIGH); 
 delay(100);
 digitalWrite(led4, LOW);
 delay(100);
 count++;
 }
 while(count < 20) {
 digitalWrite(led4, HIGH); 
 delay(100);
 digitalWrite(led4, LOW);
 delay(100);
 digitalWrite(led3, HIGH); 
 delay(100);
 digitalWrite(led3, LOW);
 delay(100);
 digitalWrite(led2, HIGH); 
 delay(100);
 digitalWrite(led2, LOW);
 delay(100);
 digitalWrite(led1, HIGH); 
 delay(100);
 digitalWrite(led1, LOW);
 delay(100);
 digitalWrite(led, HIGH); 
 delay(100);
 digitalWrite(led, LOW);
 delay(100);
 count++;
 }
 while(count < 30) {
 digitalWrite(led, HIGH); 
 delay(100);
 digitalWrite(led, LOW);
 delay(100);
 digitalWrite(led2, HIGH); 
 delay(100);
 digitalWrite(led2, LOW);
 delay(100);
 digitalWrite(led4, HIGH); 
 delay(100);
 digitalWrite(led4, LOW);
 delay(100);
 digitalWrite(led1, HIGH); 
 delay(100);
 digitalWrite(led1, LOW);
 delay(100);
 digitalWrite(led3, HIGH); 
 delay(100);
 digitalWrite(led3, LOW);
 delay(100);
 count++;
 }
 while(count < 40) {
 digitalWrite(led, HIGH); 
 delay(100);
 digitalWrite(led1, HIGH); 
 delay(100);
 digitalWrite(led2, HIGH); 
 delay(100);
 digitalWrite(led3, HIGH); 
 delay(100);
 digitalWrite(led4, HIGH); 
 delay(100);
 digitalWrite(led4, LOW);
 delay(100);
 digitalWrite(led3, LOW);
 delay(100);
 digitalWrite(led2, LOW);
 delay(100);
 digitalWrite(led1, LOW);
 delay(100);
 digitalWrite(led, LOW);
 delay(100);
 count++;
 }
 while(count < 50) {
 digitalWrite(led4, HIGH); 
 delay(100);
 digitalWrite(led3, HIGH); 
 delay(100);
 digitalWrite(led2, HIGH); 
 delay(100);
 digitalWrite(led1, HIGH); 
 delay(100);
 digitalWrite(led, HIGH); 
 delay(100);
 digitalWrite(led, LOW);
 delay(100);
 digitalWrite(led1, LOW);
 delay(100);
 digitalWrite(led2, LOW);
 delay(100);
 digitalWrite(led3, LOW);
 delay(100);
 digitalWrite(led4, LOW);
 delay(100);
 count++;
 }
 while(count < 67) {
 digitalWrite(led, HIGH); 
 delay(factor);
 digitalWrite(led1, HIGH); 
 delay(factor);
 digitalWrite(led2, HIGH); 
 delay(factor);
 digitalWrite(led3, HIGH); 
 delay(factor);
 digitalWrite(led4, HIGH); 
 delay(factor);
 digitalWrite(led, LOW);
 delay(factor);
 digitalWrite(led1, LOW);
 delay(factor);
 digitalWrite(led2, LOW);
 delay(factor);
 digitalWrite(led3, LOW);
 delay(factor);
 digitalWrite(led4, LOW);
 delay(factor);
 count++;
 factor -= 10;
 }
 while(count < 80) {
 digitalWrite(led, HIGH); 
 delay(factor);
 digitalWrite(led1, HIGH); 
 delay(factor);
 digitalWrite(led2, HIGH); 
 delay(factor);
 digitalWrite(led3, HIGH); 
 delay(factor);
 digitalWrite(led4, HIGH); 
 delay(factor);
 digitalWrite(led, LOW);
 delay(factor);
 digitalWrite(led1, LOW);
 delay(factor);
 digitalWrite(led2, LOW);
 delay(factor);
 digitalWrite(led3, LOW);
 delay(factor);
 digitalWrite(led4, LOW);
 delay(factor);
 count++;
 }
 while(count < 97) {
 digitalWrite(led4, HIGH); 
 delay(factor);
 digitalWrite(led3, HIGH); 
 delay(factor);
 digitalWrite(led2, HIGH); 
 delay(factor);
 digitalWrite(led1, HIGH); 
 delay(factor);
 digitalWrite(led, HIGH); 
 delay(factor);
 digitalWrite(led4, LOW);
 delay(factor);
 digitalWrite(led3, LOW);
 delay(factor);
 digitalWrite(led2, LOW);
 delay(factor);
 digitalWrite(led1, LOW);
 delay(factor);
 digitalWrite(led, LOW);
 delay(factor);
 count++;
 factor += 10;
 }
 while(count < 100) {
 digitalWrite(led4, HIGH); 
 digitalWrite(led3, HIGH); 
 digitalWrite(led2, HIGH); 
 digitalWrite(led1, HIGH); 
 digitalWrite(led, HIGH); 
 delay(200);
 digitalWrite(led4, LOW);
 digitalWrite(led3, LOW);
 digitalWrite(led2, LOW);
 digitalWrite(led1, LOW);
 digitalWrite(led, LOW);
 delay(200);
 count++;
 }
 factor = 200;
 count = 0;
}