Ping Pong Ball Full Colour Binary Clock

9.1K12820

Intro: Ping Pong Ball Full Colour Binary Clock

Colour changing 24Hr Binary clock using ping pong balls and full colour LED’s and a Funduino 8*8 matrix board.

I have already built a small 12Hr binary clock and fitted it into a computer, this worked very well but was only really half a binary clock (no seconds). So I decided to build a full 24hour with second’s binary clock. As I was designing the clock I decided to try and make it very colourful and pleasant to look at, so I choose full colour LED’s and used ping pong balls to make a nice diffuser! At this stage I hadn’t really thought about how I was going to drive the LED’s I initially thought about using logic gates linked to the PWM pins of the Arduino, but the more I thought about it the more difficult it was. Basically I have 20 5mm full colour LED’s, meaning I have 60 LED’s in total. so at this point I had another think about how I was going to drive all the LED’s and then realised I had the solution in a 8*8 full colour matrix, I had already used a Funduino/colorduino when I made my Plasma box, so this was a logical solution.

STEP 1: The Build

I wanted this clock to look pleasing! so the ping pong balls were the main feature and the ¼” bit of ply that they are mounted onto was cut carefully to be hidden behind the balls. You can see in the pictures that I used my favourite build method (design on a Raspberry pi using QCAD, then printed and glued to the wood)

I choose to drill all the holes using a holesaw so the balls sit nicely on the plywood. I then got my little girl to “paint” the ply wood using black ink.

Then the balls were glued to the wood using a glue gun.

Then working from the back and with the ping pong balls resting on a cloth (so they don’t get scratched) I pierced each ping pong ball with the tip of a soldering iron, then cleaned up the hole with a file.

The LED legs were then bent over at different heights and directions so I could wire up each red blue green up in columns (6) and the common positive in rows(4). You should be able to see the detail in the photos, I added a small piece of insulation to the wire where it goes over another wire. The top three LED’s were wired up using black wire for the positive leg.

At this stage I quickly tested all the LEDS using a Multimeter on Diode test. This will light the led with a small voltage.

Once I was happy that all the LED’s were ok, I added different coloured wires to each row and column. 22 in total (3 for each column and 4 positive wires)

I then added a small platform above the connecting wires and fitted the funduino.

Next each wire needed to be soldered to pins on the funduino, and more importantly they needed to be out in the correct place,

Seconds Units pin 8

Seconds Tens pin 7

Minutes Units pin 6

Minutes Tens pin 5

Hours Units pin 4

Hours Tens pin 3

In all cases you will have 3 wires (red, blue and green)

Then the 4 positive wires go to

Bottom row pin 8

Second row pin 7

Third row pin 6

Top row pin 5

STEP 2: The Program Explained

Firstly I should point out that I am not very good at programming, however I have improved! My first attempt at a binary clock was very long winded, and I have managed to improve the code considerably.

So the first thing we do is read the time, which is very easy.

(RTC.read(tm))

Then the next bit is to take each value and split it into units and tens AND if the value is less than 10 then make the tens value zero. This routine is run 3 times for the hours minutes and seconds.

void binaryOutput(int number)

{

if (number >= 10)

{

int tens = number/10;

int units = number - (tens*10);

setBinary(units,ROW);

ROW = ROW + 1;

setBinary(tens,ROW);

}

else

{

int tens = 0;

int units = number;

setBinary(ROW,units);

ROW = ROW + 1;

setBinary(ROW,tens);

}

}

You should be able to see that once you have split the number into tens and units you then run another routine to display the value in a Column. This routine take the 0-9 number and converts it to a binary number and turns on (and OFF) the required LED’s

This part of the program was the bit that improved so much from the last attempt! basically each row is treated the same independent of the number of LED’s in the row. which means the units rows have 4 LED’s and the hour Tens only has two LED’s but runs though the same routine, the Funduino doesn’t know that there isnt an LED in the position and any way the unused LED’s would be set to off.

void setBinary(int value, int whichRow)

{

ROW = whichRow;

int XYZ = 8;

int COL = 3;

for (int i = 0; i < 4; i ++)

{

getColor(g);

if (value >= XYZ)

{

Colorduino.SetPixel(ROW,COL,A,B,C);

value = value - XYZ;

}

else

{

Colorduino.SetPixel(ROW,COL,0,0,0);

}

XYZ = XYZ / 2;

COL = COL - 1;

}

}

So how does this bit of code work?? The routine is supplied with two pieces of data, which ROW and the number. XYZ is initially set to 8 and COL set to 3. So you then get the colour code and do 4 loops, on each loop you compare your number with XYZ and determine if it is more, if its more then the top LED should be turned on (the number 8 led!) Then 8 should be subtracted from your number. If its not greater than 8 then the Top LED should be turned off. In both cases you then divide XYZ by 2 and decrement the COL. then you loop again this time checking if your number is greater than 4, and so on. See below for an example.

Number is 6.

Loop1 (input number = 6, XYZ = 8, Col = 3) is it equal to or more than 8? NO turn off top light, Half the XYZ, decrement the Col.

Loop2 (input number = 6, XYZ = 4, Col = 2) is it equal to or more than 4? YES turn on the 3rd light, subtract 4 from the number, half the XYZ and decrement the Col.

Loop3 (input number = 2, XYZ = 2, Col = 1) is it equal to or more than 2? YES turn on the 2nd light, subtract 2 from the number, half the XYZ and decrement the Col.

Loop4 (input number = 0, XYZ = 1, Col = 0) is it equal to or more than 1? NO turn off the bottom light, half the XYZ and decrement the Col

At this point you then increment the ROW reset the XYZ and Col, and do the same routine for the TENS. Then repeat for the minutes and hours.

Lastly for the code you then have to “Flip” the Colorduino page to display the new time, or if the time hasn’t changed then change the colour.

void loop()

{

tmElements_t tm;

if (RTC.read(tm))

{

binaryOutput(tm.Second);

ROW = ROW + 1;

binaryOutput(tm.Minute);

ROW = ROW + 1;

binaryOutput(tm.Hour);

ROW = 0;

}

Colorduino.FlipPage();

}

So that handles the reading and displaying the time, now let’s have a look at the colours. Each Column is set to a colour and the next Column is changed by a value determine by “increment” the larger the number the better the colour variation over the 6 columns. I found that around 8 - 12 is a good number. The colour are decided by a routine which takes the value of “g” (then called rainbow) one colour is incremented, another is decremented and the 3rd is set to zero, this then cycles up and down through all the colours and gives a nice rainbow effect (see the graph for a better explanation) . One problem I had which took a very long time to work out the very simple soloution was how to make the rainbow move slowly across the columns. because I have stepped the colour between each row, if I now want to increment each column by only 1 then I have to take into consideration what the original colour number was and reset "g" to that number then add one. I think that makes sense.

So the last thing is how do you adjust the time???

I wasn’t really sure how I was going to adjust this clock when I started to build this clock, but because there are no inputs available on the colorduino board, I made a GPS clock which you can connect the RTC unit to and correct the time. I will add another instructable on how I made this!!

STEP 3: The Full Program

#include <Colorduino.h>

#include <Wire.h>

#include <Time.h>
#include <DS1307RTC.h>
int R = 30;
int B = 40;
int G = 50;
int ROW = 0;
int g = 0;
int GKB = 0;
int increment = 12;
int initalG = 0;
void setup()
{
Colorduino.Init();
unsigned char whiteBalVal[3] = {28,60,44};//RGB
Colorduino.SetWhiteBal(whiteBalVal);
}
void binaryOutput(int number)
{
if (number >= 10)
{
int tens = number / 10;
int units = number - (tens * 10);
setBinary(units,ROW);
ROW = ROW + 1;
setBinary(tens,ROW);
}
else
{
int tens = 0;
int units = number;
setBinary(units,ROW);
ROW = ROW + 1;
setBinary(tens,ROW);
}
}
void setBinary(int value, int whichRow)
{
ROW = whichRow;
int XYZ = 8;
int COL = 3;
for (int i = 0; i < 4; i ++)
{
getColor(g);
if (value >= XYZ)
{
Colorduino.SetPixel(ROW,COL,R,G,B);
value = value - XYZ;
}
else
{
Colorduino.SetPixel(ROW,COL,0,0,0);
}
XYZ = XYZ / 2;
COL = COL - 1;
}
}
void getColor(int rainbow)
{
if (rainbow < 255 )
{
R = rainbow;
B = 255 - rainbow;
G = 0;
}
else if (rainbow < 511)
{
rainbow = rainbow - 255;
R = 255 - rainbow;
B = 0;
G = rainbow;
}
else
{
rainbow = rainbow - 510;
R = 0;
B = rainbow;
G = 255 - rainbow;
}
g = g + increment;
if (g > (765 - increment))
{
g = 0;
}
}
void loop()
{
tmElements_t tm;
if (RTC.read(tm))
{
initalG = g;
binaryOutput(tm.Second);
ROW = ROW + 1;
binaryOutput(tm.Minute);
ROW = ROW + 1;
binaryOutput(tm.Hour);
ROW = 0;
delay(6);
g = initalG + 1;
if (g > (765 - increment))
{
g=0;
}
}
Colorduino.FlipPage();
}

16 Comments

Hello, this is a very nice project. How do I change the code so that it works with one colour LEDs? Thanks

Thanks for your comments,
This instructable uses a controller which does the full colour mixing, i would take a look at another project using multiplexing if you're only worried about one colour. the layout and 5mm LEDs would still work but you would need a different way to drive them.

OK

First thing is that the LED should be common Anode (positive)

Then consider each column (going up). In each of the columns connect together all the red legs, then all the green then all the blue. Do the same for each column. you will connect a wire to each red, green and blue column meaning so far you have 6 * 3 connections. that then leaves the positive leg of each LED, this time they are connected horizontally you will only have 4 wire to go to these. then follow the connection detail in the above text, and just incase its not clear, the seconds units goes to pin 8, this means the red in the units seconds goes to red 8, the blue goes to blue 8 and the green goes to green 8. the positive wires run horizontally so the bottom row goes to pin 8, I hope the rest is clear.

regards Martin

Hello

I think you have missed an obvious bit of this project... It doesn't use a normal Arduino board, it uses a Funduino board which has a special multiplex drive chip capable of controlling an 8 by 8 matrix of full colour LEDs (192 LEDs). if you only want to drive one colour, then you will need 20 outputs and I am not sure if there are enough on an UNO. you may need to use shift registers. Have a look at my berlin clock, its nearer to what you want as it has 3 shift registers controlling 24 LEDs, or if you want to try out the simple clock try the first binary clock I made it only has hours and minutes.

Please could you tell me where I can get this Funduino board. When I enter Funduino into Google it comes up with only Uno boards?
And can you tell me how to wire this up.
Many thanks.
Stuart.

Hello Stuart

Sorry you have had problems.

Its clear from your post that you haven't got the colorduino library. I have to be honest I am still learning about Arduino and the library's. the library can be downloaded from

http://blog.lincomatic.com/?p=148

I am using Arduino software 1.6.5 and I have included the colorduino.h in the sketch.

("Sketch" tab then "Add file")

give it a go and if you are still having problems I will start afresh and explain how to do it.

Awesome, and who's your adorable model?

Thanks for your comments, my adorable model is one of my best "creations" my little girl 3 1/2 years old Emma. Don't worry I wont do an instructable about how I made Emma!

Awesome work - Can you share the cad file for the ply?

Thanks for your comments, I have added the pdf below.

It looks great and is a beautiful build! Nice job!!

Why did you choose hybrid binary-decimal? That confused me for a while until I figured out what you were doing. For 34 minutes, you show 011 for the 30 and 0100 for the 4. Did you consider just using 6 lights for binary 34 and showing 010010? It seems like the whole clock could be just 3 rows or columns for the 3 binary numbers: hours, minutes, seconds.

Yes true this is a "hybrid" And I have to be honest if I used 6 bits I wouldn't be able to read the time quickly! Plus with the 6 columns you get a nice colour graduation across the display.

Thanks, I had to make it colourful and bright as I am the only one who can use it as a clock!!!