Introduction: Improve Fiberoptic Display With LEDs and Micro-controller.

This lovely fibre optic bonsai tree was dead, the power supply was no where to be found, but more important, the motor was dead. This was a slow turning motor that isnt something that I can find an easy replacement for. The improvement was primarily making it portable, but also making it programmable. There are a few ways that I could have done this, but I already had something built, that would work. The circuit that I had built was running on an arduino nano, but this project looked like a good time to try the arduino mini.

This project uses:
9 RGB LEDs
a 9 LED flashlight reflector (I took one from a dead flashlight)
3 current limiting resistors for the LEDs
3 Pchannel MOSFETs
3 gate resistors for the MOSFET
Battery pack for 6v (I rewired two three battery packs to use a total of four batteries, because I didnt have a for battery pack.)

The display came with an on/off switch, and switched power jack, which I promptly wired for the battery pack so that when its plugged in, it disconnects the batteries.

This circuit treats the 9 LEDs like 1 big LED. I was building an RGB, but I could have built it using individually controlled LEDs, and it would have been more interesting. I could have controlled the LEDs with a couple TLC5940 chips, or shift registers and resistors, or even by charlieplexing, all would have been viable ways to do this same thing, and maybe next time, I'll do it differently.

I experimented with other LEDs but the results were less than ideal. First I tried candle flame LEDs heres the video.

https://www.youtube.com/watch?v=eSQFF9lvp64


I also tried a gang of fast flash color cycle LEDs. I glued about 18 together in a big blob, and tried it. Here is the video

https://www.youtube.com/watch?v=cc3ok5NHxWQ

This video shows the original parts, and the parts that make up my RGB flashlight, that I ended up using for the display.

https://www.youtube.com/watch?v=DqeuIN9O2DM

That flashlight used common cathode LEDs and P-channel MOSFETs, There are many ways to do the LEDs, you could even use LED strips, or individually controllable LEDs, or whatever you like, but this time, I used these parts.

Step 1: Gut It, and Prep It.

The first step is to remove the original parts. In this case it came with a projector lamp, color wheel, and motor. It used a lot of electricity, 12v 1000mA when it worked, and I dont know where the power supply is anyway. It used a mini phone jack, like the kind used for an earphone. Since the new version will be LEDs and a mcirocontroller, the electrical consumption was low enough for batteries, so I included some battery clips, and wired them into the power jack. in the box.

9 RGB LEDs running full (white) is 540 mA, or just over half amp current limit on USB, but we wont be doing any white, we will only have 2 colors at full brightness at any one time, so a realistic consumption is around 360mA, which is within safe limits, so I wired this for USB, even but I run it from a wall wart USB charger It runs 5v on AC/USB, but 6v on (4)batteries.

Step 2: Make a Power Cable

I found some old cables to sacrifice. I stripped the insulation, tinned the wires, and slipped a few pieces of heat shrink insulation on the cable. Since I was only using power from the USB, I clipped the data lines and left the red and black power wires. I soldered them to the appropriate  wires on the mini phone plug, and verified everything with a multimeter to make sure that I had no opens, shorts, and that the wiring was what I wanted.

Step 3: Build the New Lighting Source

This part can be done a bunch of ways, I already had something built, but if I didnt, there are lots of ways to skin this cat, A couple TLC5940 chips with common anode LEDs is a tried and true method, shift registers and resistors are also a great way to do this, even charliplexing could do this. The way that I did it can also be done with a 12v LED strip with controller and remote. The controller that I made is pretty similar to the controllers used  LED strips, only mine is programable, and designed to work with common cathode LEDs instead of common anode LEDs like used in most strips.

The photos below show it running off an arduino mini, but it originally ran from a nano.

I included some pictures below to compare the mini and nano, and the programmer that I made to program the mini. The programmer was a cheap programmer that didnt have auto reset. I followed an instructable, and modified it a little to suit my needs.

Here is the instructable about making a USB programmer, I used it to program my mini,  had to make an adapter too. You wont need to do this if you use a nano, but this was a good project to try the mini with.

https://www.instructables.com/id/Arduino-USB/

The LEDs are wires with all the reds together, the blues together, green together, and cathodes together. Its a simple matter of bending the leads from one LED down parallel so they contact the next LEDs same leads, and trim the excess leads. then solder a wire to each of the 4 contacts to the control circuit with the MOSFETs and resistors, then wire that to the microcontroller.

I've included a schematic for the LEDs and controller. You can wire it differntly, but you want to use PWM pins so I used 9, 10, 11.

https://www.youtube.com/watch?v=Do2lNCN8xzU

Step 4: Program It

Here is a picture of the programmer hooked up to the mini, getting ready for programming.

I tried a few RGB color cycle programs, but ended up severely modifying someone else program. I added some randimizations to make the display less static, and hopefully more interesting. Heres is the current version.

/*******************************************************\
* RGB_Fade                                              *
*   Created for the use of common !cathode! RGB LEDs.   *
*   Cycles through the three colors, fading in and out. *
*   The pins used must be PWM(~) pins.                  *
*                                                       *
* Author: Anthony Weber                                 *
* Date Created: April 03, 2012                          *
*                                                       *
* Slightly modified by Hippynerd (hippynurd@gmail.com)  *
* to make transitions smoother, and make the cycling   *
* more interesting.                                     *
\*******************************************************/

//Color Pin Variables
int redPin = 11; //Isn't it obvious?
int greenPin = 10;
int bluePin = 9;

// Timing Settings Variables
int fadeSpeed = 1; //This is how much each LED changes on each step.
int delaytime = 1; // delay between cycles.
int delayCount = 1;
int randCount = 10;
// note: I tried to make fadeSpeed random, but bad things happened.

//Other Variables. Don't need to change these.
int red = 0; //Starting positions.
int green = 0; //If you change these, since the code is set up
int blue = 255; //to start at blue, it might act funny on the first cycle.

int mode = 0; //0 - blue to purple, 1 - purple to red, 2 - red to yellow,
              //3 - yellow to green, 4 - green to aqua, 5 - aqua to blue
             

void setup()  { //3-5-g-6
  // declare pin 9 to be an output:
  pinMode(bluePin, OUTPUT); //blue
  pinMode(greenPin, OUTPUT); //green
  pinMode(redPin, OUTPUT); //red
}

void loop()  {
  //Light 'em!
  analogWrite(bluePin, blue);
  analogWrite(greenPin, green);
  analogWrite(redPin, red);
 
 
 
  //Now change 'em!
  if (mode == 0) { //blue to purple;
        if (red >= 255) { //change places!
      mode = 1;
      delay(delaytime*50); //dont change right away.
    } else {
      red += fadeSpeed;
    }
  } 
  else if (mode == 1) { //purple to red
  if (blue <= 0) { //change places!
      mode = 2;
      delay(delaytime*50);//dont change right away.
    } else {
      blue -= fadeSpeed;
    }
  }
  else if (mode == 2) { //red to yellow
    if (green >= 255) { //change places!
      mode = 3;
      delay(delaytime*50);//dont change right away.
    } else {
      green += fadeSpeed;///2; //I slow this down because it seems to blink by too quickly.
      //if (green > 255) green = 255;
    }
  }
  else if (mode == 3) { //yellow to green
    if (red <= 0) { //change places!
      mode = 4;
      delay(delaytime*50);//dont change right away.
    } else {
      red -= fadeSpeed;
    }
  }
  else if (mode == 4) { //green to aqua
    if (blue >= 255) { //change places!
      mode = 5;
      delay(delaytime*50);//dont change right away.
    } else {
      blue += fadeSpeed;
    }
  }
  else if (mode == 5) {//aqua to blue
    if (green <= 0) { //change places!
      mode = 0;
      delay(delaytime*50);//dont change right away.
    } else {
      green -= fadeSpeed;
    }
  }
  //This delay works pretty well, but feel free to
  //change this if you want a faster but smoother fade.
  //Changed delay to random for more fun display.
    delayCount++;
    if (delayCount >= randCount) {
      delayCount = 1;
      randCount= random (500, 5000);
      delaytime = random (1, 150); // random delays to keep things interesting
     }
  delay(delaytime);
}

Comments