Persistence of Vision Bauble. POV Decoration.
by mr_fid in Circuits > Electronics
12544 Views, 166 Favorites, 0 Comments
Persistence of Vision Bauble. POV Decoration.
Persistence Of Vision Bauble. POV decoration
It’s the time of year to get the tree up and decorate it with all the wonderful lights, tinsel and baubles. And this project is about Baubles, whenever I put decorations on a tree I can’t help but wind up the baubles and let them spin and wind themselves up again and so on. So I decided to try and make my own POV Bauble which my little children can wind up and see the different patterns.
Firstly I should point out that this has been thrown together with the bits I could find, I didn’t buy anything special and the method I have chosen is probably well over the top. (But it works well). And another thing is that I am new to Arduino programming, so I write programs in a very basic (long winded) way. And lastly there is no speed synchronisation so the patterns will change depending on the speed. (I am sure you could drive it by a motor is you wish but I just wanted it to be hand driven)
Making the Bauble
So what bits did I find to make this POV Bauble?
1 * Arduino PRO MINI 5V/16M Like a NANO?(it doesn’t have an FTDI).
8 * Full colour LEDS common Anode (positive).
3 * SN74HC573N Octal Transparent D-Type Latches (borrowed for 8*8*8 cube).
3 * 20pin DIL chip holders.
24 * 470 Ohm resistors.
1 * 1 K Ohm resistor.
1 * breadboard 33 tracks by 12/14 wide (to fit chosen tube)
9 volt battery and battery connector.
1 *20mm wide 88mm diameter (Outside 82mm inside) cardboard tube.
Lots of wire for links and connections.
Step 1. The tube and LED’s
Find a piece of tube. You could use any type of tube as long as it is no smaller than 82mm inside diameter, I happened to find a big documents tube at work and cut the end of it! (I am sure no one will notice)
Choose your LED’s I happened to have full colour common Anode LED’s but you could use common Cathode or make it really simple and only have one colour (directly driven from the Arduino)
Identify the common leg of the LEG and then bend the other 3 legs forward and backwards, do the same bends for all the 8 LED’s. Then take a bit of masking tape and draw a line 10mm from the edge and mark off 6mm spacing’s for the 8 LED’s (the picture shows this better than I can explain.) Then position the tape on the tube and pierce through the cube with a compass point.
Put all the LED’s in place on the tube and then position a piece of solid core wire underneath the legs so you can bend the Anodes over the wire and solder them to it. Once that it done it might be worth just checking that all the LED’s work.
One colour at a time trim the legs then bend them over the edge of the tube, then solder wires to each bent over leg. I choose red, green and blue wire for the respective coloured LED’s.
Lastly for this stage I painted over the bare legs with a plastic water based paint, just to seal everything in place, provide insulation and hide the shiny legs!
The Breadboard Circuit
Step 2. The bread board circuit.
So, as I have already explained I happened to have these chips (SN74HC573N) lying around so that’s what I used. They are really simple to use and explain. On the left side are the 8 inputs and on the right there are 8 outputs. You put the required code on the input then load the pattern by taking the Latch-enable (LE pin 11) HIGH then return to low. This will store the code into the output. There are also GND and Vcc pins and another pin called “NOT QE” which allows the outputs to be driven high or low, I don’t use this pin so I just pull it down using a 1K ohm resistor. And that’s it.
3 chips are used to drive the 3 different colours and the 8 input legs are joined together and the 3 LE (latch-enable) go to different pins on the Arduino to select the correct colour for the pattern sent to the inputs (that sounds really confusing but it’s not!).
Once you have soldered the 3 chip holders (tracks cut in between) then you can add the links and 24 470 Ohm resistors. (Again where the resistor is placed along the track a track-break has to be cut in between the legs (see the photos). Then just one last resistor to pull down the commoned “NOT QE” pins to ground. (1K ohm)
Once you are happy with the breadboard then file the ends to suit the tube you have and glue the board into the back of the tube as shown in one of the pictures. Then one colour at a time solder the wires connected to the LED legs onto the edge of the board so they are connected to the output resistors. Then connect the Arduino wires and lastly the power.
The Arduino PRO MINI 5V/16M
Step 3. The Arduino PRO MINI 5V/16M
I happened to have a few of these lying around which I had got form the internet for about £2.50. I decided to keep things simple and wired the 8 outputs to pins 2 to 9 colour coded accordingly! And the 3 LE connections were made to A0, A1 and A2 (which you can use as digital pins by adding 14 to the pin number I.E. pins 14, 15 and 16) again I coloured these red, blue and green to match with the LED’s.
The power is via a 9Volt battery which goes to the “RAW” and GND connections on the Arduino, and the breadboard is powered via wires from the 5V and GND (or GDN on my cheap clone!) and that’s it.
Make it nice and neat so it all fits in the tube and looks pretty! You could add a front and back but I wanted to leave it open so everyone could see what’s inside!
AND one last thing, you can see in one of the pictures how the whole thing fits together, however you might not be able to see the sellotape that has been wrapped around the battery and Arduino to avoid shorts.
Step 4. the Programming.
Step 4. The programming.
I am new to Arduinos so I am still picking up the language and working it out. The first test I did was to turn on and off each LED in turn then cycle through the 3 colours, I put a nice delay in and could then check all the LED’s were working. Next I reduced the delay and tried spinning the bauble. I was very surprised it work as well as it did. So now I am trying to sort out the code to make nice patterns.
I am keeping it basic so you only have 7 colours to choose from
1. Red.
2. Red/green.
3. Red/blue.
4. Green.
5. Green/blue.
6. Blue.
7. White (all three).
So I spent a long time trying to get the code better, I know it can still be vastly improved but I was very pleased to get to this stage. So detailed below is how the program works.
Firstly configure all the output pins and name accordingly.
Then for each vertical row of 8 LED’s send an 8 bit number for each colour you wish to turn on then follow with a delay.
i.e. turnOnLEDs(7,24,224); top 3 LED’s green, 4th and 5th blue, and 6,7,8 red.
i.e. turnOnLEDs(89,106,116); see photo for working out.
My problem came when I tried to set the required output LED’s to the 3, eight bit numbers and I overcame this by checking whether the number was greater than 127 (i.e. 128 or more) if it was greater than 127 then the most significate bit must be set so turn on the LED in position 8, Then minus 128 from the number. (if the number wasn’t greater than 127 then do nothing) Next check whether the number is greater than 63 (i.e. 64 or more) and again if it is then turn on the LED in position 7 and subtract 64 from the number. AND SO ON. And then repeat
the 8 steps for the next two colours. I am sure that is as clear as mud, but if you look at the program below (and picture of worked example) and work it out for a given number you should see what it is doing. Once you have worked out what should be on and off you then load this value into the Octal latch by taking the required colour pin HIGH then LOW.
Then all you need to do is make up patterns and loop through that as you want. I have only included one part of one pattern, it’s the slanting lines but only the green line, all you have to do is cut and paste that first section and change the colour code. Or just create you own pattern using loops etc.
The Code
The code bit!
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
int led8 = 9;
int green = 14;
int blue = 15;
int red = 16;
void setup()
{
pinMode (led1,OUTPUT);
pinMode (led2,OUTPUT);
pinMode (led3,OUTPUT);
pinMode (led4,OUTPUT);
pinMode (led5,OUTPUT);
pinMode (led6,OUTPUT);
pinMode (led7,OUTPUT);
pinMode (led8,OUTPUT);
pinMode (green,OUTPUT);
pinMode (blue,OUTPUT);
pinMode (red,OUTPUT);
}
void loop()
{
pattern01(200);
}
void pattern01(int loops3)
{
for (int j = 0; j < loops3; j ++)
{
turnOnLEDs(0,0,0);
delay1();
turnOnLEDs(1,0,0);
delay1();
turnOnLEDs(2,0,0);
delay1();
turnOnLEDs(4,0,0);
delay1();
turnOnLEDs(8,0,0);
delay1();
turnOnLEDs(16,0,0);
delay1();
turnOnLEDs(32,0,0);
delay1();
turnOnLEDs(64,0,0);
delay1();
turnOnLEDs(128,0,0);
delay1();
}
}
void turnOnLEDs(int LEDValue, int LEDValue2, int LEDValue3)
{
for (int j = 1; j < 4; j ++)
{
if (LEDValue > 127)
{
digitalWrite(led8, LOW);
LEDValue = (LEDValue - 128);
}
else
{
digitalWrite(led8, HIGH);
}
if (LEDValue > 63)
{
digitalWrite(led7, LOW);
LEDValue = (LEDValue - 64);
}
else
{
digitalWrite(led7, HIGH);
}
if (LEDValue > 31)
{
digitalWrite(led6, LOW);
LEDValue = LEDValue - 32;
}
else
{
digitalWrite(led6, HIGH);
}
if (LEDValue > 15)
{
digitalWrite(led5, LOW);
LEDValue = LEDValue - 16;
}
else
{
digitalWrite(led5, HIGH);
}
if (LEDValue > 7)
{
digitalWrite(led4, LOW);
LEDValue = LEDValue - 8;
}
else
{
digitalWrite(led4, HIGH);
}
if (LEDValue > 3)
{
digitalWrite(led3, LOW);
LEDValue = LEDValue - 4;
}
else
{
digitalWrite(led3, HIGH);
}
if (LEDValue > 1)
{
digitalWrite(led2, LOW);
LEDValue = LEDValue - 2;
}
else
{
digitalWrite(led2, HIGH);
}
if (LEDValue > 0)
{
digitalWrite(led1, LOW);
}
else
{
digitalWrite(led1, HIGH);
}
if (j == 1)
{
digitalWrite(green, HIGH);
digitalWrite(green, LOW);
LEDValue = LEDValue2;
}
else if (j == 2)
{
digitalWrite(blue, HIGH);
digitalWrite(blue, LOW);
LEDValue = LEDValue3;
}
else if (j == 3)
{
digitalWrite(red, HIGH);
digitalWrite(red, LOW);
}
}
}
void delay1()
{
delay(1);
}