Starduino

3 June 2010

About a 10-minute read

Please Note: I’m still writing this page. You may find it useful as-is, but much more in the way of pictures and the final steps is coming.

The Starduino is my first big Arduino project. It’s an LED lamp based on an Indian paper star lantern. I personally think it came out very nicely, and I hope to allow others to enjoy it as much as I did by sharing a how-to on this site.

The Materials

This project doesn’t require too much. The main thing, of course, is an Arduino for the heart of the thing. To keep the cost down and avoid being wasteful, I decided to use an Arduino clone called the RBBB (Really Bare Bones Board) from moderndevice. This board is eventually embedded in the star lantern, so I had to be okay with saying goodbye to the lucky Arduino that gets to power it. In addition, the project calls for:

  • LEDs

  • Soft White (or your color of choice) LED x50 (2 of these at Amazon)

  • Wires

  • Hookup Wire AWG 30 (Radioshack)

  • Hookup Wire AWG 22 (Radioshack)

  • Alarm Wire 30 ft. (9 m) - Four-conductor, AWG 22 per strand or bigger (like: Lowe’s)

  • Integrated Circuits (ICs)

  • Adjustable Voltage Regulator (LM317 or compatible with heatsink) x1 (Radioshack)

  • Resistors

  • 0.25 Watt: 220Ω x1 (Radioshack)

  • Capacitors

  • 1-10 µF (your choice) x1 (Radioshack)

  • 0.1 µF x1 (Radioshack)

  • Potentiometers

  • Trimmer Potentiometer 5+ kΩ x1 (Radioshack)

  • Rotary Potentiometer 10 kΩ x1 (Radioshack)

  • Switches

  • Switch 1.0A or greater x1 (Radioshack)

  • Power Supplies

  • AC-DC Wall Adapter 7.5V or greater, 1A or greater (Radioshack)

  • Transistors

  • NPN Transistor 0.6W or greater (3V × 0.2A) x5 (Radioshack)

  • Microcontrollers

  • Arduino or compatible clone (I used the RBBB) x1

  • Circuit Boards

  • Breadboard/Perfboard/PCB x1 (Custom Starduino PCB in the works!) (Solderless or Perf)

  • Tools & Craft Items

  • Standard clear drinking straw x10 (Your local café or restaurant)

  • Hot glue gun & glue (Amazon)

  • Plastic project box or similar to house the AC adapter & Switch/Pot (Radioshack)

  • Paper Star (I used white) x1 (Whirled Planet Wholesale)

And some optional pieces:

  • 5-pin Male header (Sparkfun)
  • 5-pin Female header (Sparkfun)
  • FTDI USB-to-Serial Converter (If your Arduino of choice has no USB port like the RBBB) (Sparkfun)

Some Key Notes on Materials

You can expect to pay the most on LEDs, the paper star, and the Arduino. These three things also happen to be the most central to your Starduino’s success. Make sure your LEDs are 3.3V-compatible and 20mA or fewer! Though humble by themselves, together these LEDs drink a significant amount of juice. Using 5V or higher-current LEDs will overheat your LM317, your power supply, and/or your Arduino. This can be a fire hazard, so please check the ratings on all parts to ensure they correspond to those listed here.

The other critical piece is the AC-DC “wall wart.” While a generic, basic one will do, if you have some extra room in your budget a quality power supply is a good investment. Any “wiggle” in the supplied voltage will show up as flickering in the LEDs when dimmed down low, so keep this in mind while choosing a supply. Also, a quick safety note: Starduino needs 1 Ampere and at least 7.5V or greater to run safely and as-intended. Check the current rating, as a brick rated under 1A could start a fire when the star lights up!

Begin the Build!

Have all those materials? Good! Now it’s time to begin the build. Here’s a brief overview of he whole process:

  1. Construct the RBBB kit
  2. Construct the LED tubes
  3. Mount the LED tubes
  4. Build the brains
  5. Construct the switch/power box (the life-source!)
  6. Mix it all together!

1: The Arduino

Arduino is the brain behind the star’s awesome light patterns. By programming it, you can control your Starduino’s brightness, the order it lights concentric rings of light, and the speed of the undulations. So, it is fitting to start construction here. If you ordered an RBBB Kit like I did, you can find excellent documentation on its page. Alternatively, the same page offers a fully-assembled, tested RBBB for a bit more money.

When you’ve completed the construction (or finished that challenging unwrapping of your pre-built product :)), test your Arduino! Plug it in, make sure the LEDs blink, and try uploading a simple sketch. If you’ve never seen an Arduino before, or need a refresher, check out the official documentation for help.

2: The Tubes

The “tubes” will serve as the basic building block within the Starduino. Each one houses five (5) LEDs, with each of their inputs and one common ground wire. I used standard clear drinking straws to hold the strips of LEDs, which worked well and proved extremely cheap (actually free, as I found the straws in various cafeterias and cafés).

The complicating factor with this setup is that the LEDs are wired together in groups of ten (10). However, these group members are not physically located near one another. Instead, the LEDs are wired together in concentric rings, so that the star can create a cool radial “jellyfish” motion with its lights. This means that the LEDs in each straw each need discreet wires, and to keep the star pretty these wires shouldn’t cross through the center of each point (this also makes installation much easier).

So, knowing that we will end up with a large tangle of cables, we can journey into the build!

Cutting the Straws

Unwrap all the straws. Using scissors, make a straight cut all the way down the back of each straw length-wise. This will allow us to hold the straws open to run the wires inside.

Marking the Straws

Now, measure 2 cm from one end, and begin measuring here. Using a permanent marker make a dot every 4 cm until you’ve made five (5) dots. Also, mark the end of the straw from which you measured. (This means the first dot will be 2 + 4 = 6 cm from the end.) Once you’ve marked all the straws, move on.

Poking Holes

Now, using a small sharp tool (I used an open safety pin), poke one hole at each mark, on the opposite side of the straw from the slit. Then, going back over the straw, poke another hole beside each one, approximately 5 mm away. These two holes will hold the LED leads, so it’s a good idea to check that an LED fits in one of your hole-pairs every once in a while. The secondary holes should all be on the same side of their mark, so that the LEDs are evenly spaced.

Placing the Lights

Place five LEDs in each straw. It’s helpful to keep all the polarities the same direction, so I recommend placing the positive (longer) lead through the hold with the marker mark, and the shorter lead through the other hole. The leads will stick out through the slit in the back of the straw. Leave them unbent for now.

Wiring the Lights

Time to hook up all the wires! This part can be a bit tricky. You will need to cut the following lengths of wire:

  • 30 AWG, 50 cm x 10
  • 30 AWG, 46 cm x 10
  • 30 AWG, 42 cm x 10
  • 30 AWG, 38 cm x 10
  • 30 AWG, 34 cm x 10
  • 22 AWG, 50 cm x 10

Strip at both ends of every 30 AWG strand.

For each 22 AWG strand: Strip one end like normal. On the other end, strip a longer amount, like 5 cm. Then, working back from this longer free end, strip every 3 cm, sliding the insulation down the wire such that each bare patch is about the same length. This creates a ground-wire rail for all the LEDs, insulated from the other wiring.

Now, note the end of the straw you marked earlier. This will be the closest to the center of the star. Take one of the ground wires, and twist the negative (shorter!) lead of each LED around the bare patches on the wire. Tuck the twisted bits up into the straw so they’re out of the way.

Working from the marked end out, wire the shortest wire to the first LED, the next-shortest to the next LED, and so on, so that the longest wire is twisted around the positive lead of the final LED. Tuck all of these wires into the straw, so that six (6) wires now spill out of the marked end, and the slit falls closed. Tape the end of the straw and all the wires together to protect the wires from being pulled out.

Using the marker, somehow mark the numerical code of each positive wire: “1” for the closest (shortest) wire, “2” for the second, and so on, using “5” for the longest positive wire. These numbers will be important later. I used dots on the wires corresponding to the number code, though any similar system works fine.

Repeat for each straw, and then set these light modules aside.

3: Mounting the Tubes

Open the Star

The first step here is opening up your star. Gently work the points apart, and help guide the creases as the star unfolds. Go slow to avoid tearing and bending the points. When you’ve opened it all the way, tie the string at the top with a removable bow so that the star doesn’t fall closed. Now gently crease the top and bottom of each point, so that you create a nice cradle on the inside. Once you’ve broken the star in a bit, you can untie the string and close the star.

Glue in the Tubes

Heat up the hot glue gun, and gather your light tubes. When the glue is hot, run a generous helping down the slit end of one straw, and place the straw, wires out, in the valley of one of the star points as shown. Make sure it’s thoroughly stuck, then do the same for all the straws.

Gather the Wires

This bit can prove somewhat tedious. The goal is to bundle all the ground wires, all the “1” wires, all the “2” wires, etc., into groups of ten (10), such that you end up with five (5) groups of positive leads and one (1) group of negatives. Gather all the wires for a group, and twist the ends together consistently. Be careful with the 30-gauge wire, as it is easy to break the stripped ends (fingers work better than pliers here). Take a short bit of stripped 22-gauge and twist it around the bunch, so that it extends out the end as a single “plug.”

If you opted to buy the headers or have some around, attach this single larger plug wire to one of the male header pins as shown. If you don’t have the pins, leave the wire exposed.

4: Build the Brains

This is the fun part. The circuit driving the Starduino is fairly simple. It’s centered around a slightly modified RBBB, with some of the pins removed for simplicity. So, begin the build with the RBBB:

The Arduino

The RBBB will only need one analog-in pin. It will also need five (5) PWM pins for driving the concentric rings of LEDs. The unregulated voltage-in, ground, and 5V-out also need pins. So, in all, assemble the RBBB with nine (9) pins:

  1. PWM pin #3
  2. PWM pin #5
  3. PWM pin #6
  4. PWM pin #9
  5. PWM pin #10
  6. +V
  7. GND
  8. Analog in #5
  9. 5V out (near analog)

You can snip off the back end of the board with the power jack (as I did) to save space, though this is optional.

The PCB

The first Starduino I made used point-to-point wire wrapping for connections, all anchored on a perforated breadboard. This was quick to assemble and relatively easy, though I decided a PCB would really dress up the end result. I designed the thing in Fritzing, and printed it on a laser printer. Then etching the board is a matter of ironing the toner onto the copper PCB and putting the whole thing in a copper etchant. See details below:

  1. Print the pattern
  2. The PCB traces for Starduino

5: The Switch Box

Now, to create a tidy switch box, you’ll need to cut your project box. Because power bricks, potentiometers, and switches can all vary in size, you should check measurements with your own equipment before you cut anything.

I tried to keep my switch box as basic and easy-to-construct as possible. The power adapter is inside, with the prongs sticking through a rectangular cutout in the back. The switch and potentiometer both mount in standard drilled holes. In addition, drill a hole for the 4-core wire somewhere discreet in the box. Before mounting the pieces though, some wiring is in order.

First cut the cord of the power brick about 5” (~10 cm) from the device. Cut the insulation holding the two stands together, and strip a generous amount off the wire tips. Peel the wires apart so you have room to work. You may want to twist the stands together if you have a stranded cord. Now attach the black strand of alarm wire to the power source ground. Check with a voltmeter to make sure you know the polarity. Run the positive power wire through the switch, then to the red alarm strand. Attach the yellow wire to the right-hand potentiometer lead (when viewed from the knob side, with contacts on top). Attach the green wire to the middle (wiper) lead.

Run the rest of the alarm wire through the hole you drilled, and make a retaining knot to keep it from being yanked out. Make a seal of hot glue to finish it nicely. Glue the power supply to the plate with the hole in it. Fasten down the switch and the potentiometer, and screw the whole assembly together. Power supply, check!

6: Mix it All Together!

Almost done! Somehow connect the alarm wire to the breadboard (I tied mine to a hole). This will hold the weight of the star, so make it nice and tight!

Wire the red alarm wire to the power in on your breadboard, the black to ground, the yellow to the Arduino’s +5V pin, and the green to analog in. The code looks on analog pin #3 by default, though you can change this in the list of variables at the top.

Now plug the LED wire bundles into their corresponding ports. (See “4: Build The Brains” for details). Attach the common ground as well. Plug your creation into the wall, and power it up! It should light up, and change when you turn the potentiometer. If something’s dark or suddenly smells funny, unplug and check your wiring and solder joints. If all went well, you’re the proud new parent of your very own Starduino!

The Code

Still need that source code? The first version is available below. It’s governed by a CC Attribution Share-Alike license, so feel free to use and modify it however you see fit (so long as you attribute the original to my name, and share your creation freely as well).

Below is the current source code for the Starduino project! I hope someone out there will find it as fun as I do. It was tested and deployed with Arduino 0018, though will likely work on most (if not all) previous releases. Enjoy!

Creative Commons License

Starduino by Travis Geis is licensed under a [Creative Commons Attribution-Share Alike 3.0 United States License](http://creativecommons.org/licenses/by-sa/3.0/us/).
/*
Starduino by Travis Geis

for Emily Rolen
with love...

Version 1
Wednesday 2 June 2010
*/

const int ONEPIN = 3, TWOPIN = 5, THREEPIN = 6, FOURPIN = 9, FIVEPIN = 10, POTPIN = 3;
int currentOne, currentTwo, currentThree, currentFour, currentFive = 0; //On a scale of 256 (direct output values, NOT percentages!)
int maxBrightness, minBrightness, brightnessOffset;
double spacing, potValue, crossover, lowerBuffer, upperBuffer;
const int sampleNumber = 100;
int potSamples[sampleNumber];
int currentIndex = 0;
unsigned long total = 0;

void setup(){
  //init pot sample array
  for(int i = 0; i < sampleNumber; i++){
    potSamples[i] = 0;
  }
  spacing = 0.5; //radians on a sinusoid
  maxBrightness = 100; //percent
  minBrightness = 0; //percent
  brightnessOffset = 100; //percent
  crossover = 50; //percent
  lowerBuffer = 0; //use these buffers if the lower percentage of each half-pot is flaky
  upperBuffer = 0; //measures in percent
  pinMode(ONEPIN, OUTPUT);
  pinMode(TWOPIN, OUTPUT);
  pinMode(THREEPIN, OUTPUT);
  pinMode(FOURPIN, OUTPUT);
  pinMode(FIVEPIN, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  static double time; //looping counter for wave function
  if(time > 2*PI){
    time = 0;
  }
  potValue = readPotPercent(); //Percent
  //Serial.println(potValue);
  if(potValue >= 0 + lowerBuffer && potValue < crossover){
    double brightness = (double) potValue / (double) crossover * 100;
    showLightPercentage(brightness, brightness, brightness, brightness, brightness);
  }else if(potValue >= crossover + upperBuffer && potValue <= 100){
    maxBrightness = (double) (potValue - crossover) / (double) (100 - crossover) * 100.0;
    //CONSTANT FOR NOW //minBrightness = max(0, maxBrightness - brightnessOffset); //whichever's bigger: 0 or the subtraction
    showLightPercentage(wave(time + (2 * spacing)), wave(time + spacing), wave(time), wave(time - spacing), wave(time - (2 * spacing)));
  }else{
    showLightPercentage(100, 100, 100, 100, 100);
  }
  time += 0.005;
  delay(1);
}
double wave(double time){ //returns a percentage
  return ( (double) (maxBrightness - minBrightness) / 2.0 ) * (cos(time) + 1.0) + minBrightness;
}
void showLight(int one, int two, int three, int four, int five){
  analogWrite(ONEPIN, one);
  analogWrite(TWOPIN, two);
  analogWrite(THREEPIN, three);
  analogWrite(FOURPIN, four);
  analogWrite(FIVEPIN, five);
}
void showLightPercentage(double one, double two, double three, double four, double five){
  showLight(one * 2.55, two * 2.55, three * 2.55, four * 2.55, five * 2.55);
}
int readPot(){
  //this method is smoothed and so experiences a slight lag behind actual values
  //but is much more stable
  total -= potSamples[currentIndex]; //subract the oldest entry
  potSamples[currentIndex] = analogRead(POTPIN); //read the pot and log it in the array
  total += potSamples[currentIndex]; //add the newest
  currentIndex++; //move the index forward one
  if(currentIndex >= sampleNumber) //wrap around if needed
    currentIndex = 0;
  return total / sampleNumber; //preserve decimals until after division
}
double readPotPercent(){
  return readPot() / 10.23; //(dividing by 1023 quanta of resolution and multiplying by 100 percent)
}

Comments