Lite Brite LED Clock
Lite Brite pegs look like LED's don't they? That's what I though the other day after working on an LED cube for a few hours. I happened to see my daughter's Lite Brite sitting there, and I looked at the pile of LED's on my desk. What a perfect match!
In this instructable I will show you how to make a Lite Brite clock using a Lite Brite, an Arduino, 46 LED's and a few other miscellaneous parts.
This project is an upper-beginner level project. The most difficult part of building the Lite Brite clock is the soldering. The soldering is fairly detailed and intricate. You can very easily short two leads or two wires together, or break solder joints when you're closing the project up. You need to be very precise and detailed in your inspection of your work.
The code I wrote is fairly straightforward, and you can either just use my code, or use it as an example to come up with your own. I don't claim to be a programmer, but i get by.
You can find more about the Lite Brite clock at my blog at http://www.meanpc.com/2012/08/arduino-lite-brite-clock-project_3.html
Ready to build? Let's go!
I documented nearly the entire build with a video camera and photos. Watching the video is not necessary if you follow the steps, but it might help you through some tricky parts. Always be sure to defer to the written instruction when there is a difference. I changed my mind about several things during the build and they had to be redone - but I left the video intact so you could see the entire process.
In this instructable I will show you how to make a Lite Brite clock using a Lite Brite, an Arduino, 46 LED's and a few other miscellaneous parts.
This project is an upper-beginner level project. The most difficult part of building the Lite Brite clock is the soldering. The soldering is fairly detailed and intricate. You can very easily short two leads or two wires together, or break solder joints when you're closing the project up. You need to be very precise and detailed in your inspection of your work.
The code I wrote is fairly straightforward, and you can either just use my code, or use it as an example to come up with your own. I don't claim to be a programmer, but i get by.
You can find more about the Lite Brite clock at my blog at http://www.meanpc.com/2012/08/arduino-lite-brite-clock-project_3.html
Ready to build? Let's go!
I documented nearly the entire build with a video camera and photos. Watching the video is not necessary if you follow the steps, but it might help you through some tricky parts. Always be sure to defer to the written instruction when there is a difference. I changed my mind about several things during the build and they had to be redone - but I left the video intact so you could see the entire process.
Parts and Tools
Note: The parts in the following list have changed since the video was shot. Use the parts below.
Parts
1 Lite Brite
1 Arduino Uno or equivalent.
46 LED's - I used 5mm. Diffused LED's will save you some work.
Twelve 100 ohm 1/4 watt resistors
Hookup wire - 20 or 22 gauge, or both. For wires connecting to the Arduino, I recommend 20 gauge for a tight fit.
Small perfboard, breadboard or whatever you would like to use to mount the 12 resistors feeding each column of LED's. I used a small piece of perfboard.
Velcro - applied to the back of the Arduino and perfboard and the inside of the Lite Brite to secure the electronics.
Black construction paper - alternatively, you could use some of the paper that came with the Lite Brite if you still have it.
Solder
Tools
Needle nose pliers
Diagonal cutters
Wire strippers
Scissors
Soldering iron
Multimeter
Sandpaper or sanding block if you don't use diffuse LED's. I used a 320 grit sanding sponge.
Optional - alligator clips - I found these very helpful when testing the LED matrix.
Parts
1 Lite Brite
1 Arduino Uno or equivalent.
46 LED's - I used 5mm. Diffused LED's will save you some work.
Twelve 100 ohm 1/4 watt resistors
Hookup wire - 20 or 22 gauge, or both. For wires connecting to the Arduino, I recommend 20 gauge for a tight fit.
Small perfboard, breadboard or whatever you would like to use to mount the 12 resistors feeding each column of LED's. I used a small piece of perfboard.
Velcro - applied to the back of the Arduino and perfboard and the inside of the Lite Brite to secure the electronics.
Black construction paper - alternatively, you could use some of the paper that came with the Lite Brite if you still have it.
Solder
Tools
Needle nose pliers
Diagonal cutters
Wire strippers
Scissors
Soldering iron
Multimeter
Sandpaper or sanding block if you don't use diffuse LED's. I used a 320 grit sanding sponge.
Optional - alligator clips - I found these very helpful when testing the LED matrix.
Diffuse the LED's
If you bought diffused LED's, you can skip this step. If not....
We want to use diffused LED's for a couple of reasons. If the LED's are clear, they will shine outward instead of just lighting themselves up. Shining outward will make them too bright and can also illuminate surrounding LED's, which will make it difficult to tell which LED's are actually lit up. The desired effect is for the LED to glow instead of shine.
Take your sandpaper and vigorously buff the the entire surface of each LED. The LED should look cloudy all over when you are done. Please reference the photos and video below to see how it is done and how your finished product should look. It took me around a half hour to diffuse 46 LED's. If I had planned properly, I think I would have bought them already diffused - it would have been worth it.
We want to use diffused LED's for a couple of reasons. If the LED's are clear, they will shine outward instead of just lighting themselves up. Shining outward will make them too bright and can also illuminate surrounding LED's, which will make it difficult to tell which LED's are actually lit up. The desired effect is for the LED to glow instead of shine.
Take your sandpaper and vigorously buff the the entire surface of each LED. The LED should look cloudy all over when you are done. Please reference the photos and video below to see how it is done and how your finished product should look. It took me around a half hour to diffuse 46 LED's. If I had planned properly, I think I would have bought them already diffused - it would have been worth it.
Cut Construction Paper to Size
If you have the paper that came with the Lite Brite, you can skip this step.
Cut a piece of black construction paper to fit the Lite Brite.
Cut a piece of black construction paper to fit the Lite Brite.
Layout and Place LED's
Now we are going to layout the LED's on our Lite Brite. I did a quick drawing on the white board that you can see below. With this design, you will need 13 LED's for each of three numbers, 5 LED's for the one, and two LED's for the colon.
The first step is to use your Lite Brite pegs to figure out how you will position your LED's.
Once you have a very good idea how you will position the LED's, put your black paper in. Now we will punch holes in every position that an LED will be in. Use a Lite Brite peg to make the holes. Be very careful to make sure you are punching holes in the right places. As you can tell from the picture below, I was not careful enough, and had several mistakes. I ended up patching these holes with very small pieces of construction paper and glue, and it came out fine.
Once you have all the holes punched, go ahead and stick your first row of LED's in, and splay the leads to hold them in place.
The first step is to use your Lite Brite pegs to figure out how you will position your LED's.
Once you have a very good idea how you will position the LED's, put your black paper in. Now we will punch holes in every position that an LED will be in. Use a Lite Brite peg to make the holes. Be very careful to make sure you are punching holes in the right places. As you can tell from the picture below, I was not careful enough, and had several mistakes. I ended up patching these holes with very small pieces of construction paper and glue, and it came out fine.
Once you have all the holes punched, go ahead and stick your first row of LED's in, and splay the leads to hold them in place.
How to Test Your LED's
In the next few steps, we will be soldering our LED's down. We need to make sure the LED's have the right polarity. Because we have splayed the leads to hold the LED's in place, it is difficult to identify the short lead, or cathode of the LED.
To be 100% certain your polarity is correct before you solder, make a quick test setup. Apply power to the LED using a battery and some alligator clips. Also, BE SURE TO USE A RESISTOR!, especially if you test with a 9 volt battery or higher. If you don't believe you need the resistor, watch the video below.
Make dead certain you know the polarity of each LED just before you solder it. A little bit of extra care now can save a ton of troubleshooting later.
To be 100% certain your polarity is correct before you solder, make a quick test setup. Apply power to the LED using a battery and some alligator clips. Also, BE SURE TO USE A RESISTOR!, especially if you test with a 9 volt battery or higher. If you don't believe you need the resistor, watch the video below.
Make dead certain you know the polarity of each LED just before you solder it. A little bit of extra care now can save a ton of troubleshooting later.
Solder the Cathodes of Each Row Together
Solder the cathodes of each of the five rows together. The cathode is the short or negative end of the LED. You will end up with 5 rows of cathodes that are all tied together. For now, do nothing with the anodes.
Some of the cathodes will be too far apart to solder together. Simply cut and strip some jumper wire for those stretches. Make a small hook on the end of the wire and the LED lead, then squeeze gently. This should make it relatively easy to solder the jumpers in.
Some of the cathodes will be too far apart to solder together. Simply cut and strip some jumper wire for those stretches. Make a small hook on the end of the wire and the LED lead, then squeeze gently. This should make it relatively easy to solder the jumpers in.
Solder the Anodes
Time to solder the anodes together. The anodes are running vertically, and you have 10 columns of anodes to tie together. I chose to simply strip a piece of hookup wire, make loops in the wire, tighten the loops with my needle nose, then solder. The anodes were pretty easy compared to the cathodes. Be very careful not to short the anodes and cathodes together - this could be a real PITA to troubleshoot later.
When you get done, use your LED tester to test each LED, as seen in the video below.
When you get done, use your LED tester to test each LED, as seen in the video below.
You will now solder hookup wire to the anodes and cathodes. Going across the top, you will be soldering 10 hookup wires. Going down, you will solder hookup wire to the 5 rows of cathodes.
CAUTION: Do not hookup the leads to the colon in this step.
The easiest method to connect the wires to the leads is to make a small hook on each, then squeeze them together. This will hold the joint while you solder.
How much slack do you need in the wires? That's up to you really. The 10 anodes will each be connecting to a perfboard or breadboard where the 100 ohm resistors are. The 5 cathodes can connect directly to the Arduino. Be sure to think for a minute how your boards will be laid out. Also make sure to give yourself plenty of slack to open and close the Lite Brite.
CAUTION: Do not hookup the leads to the colon in this step.
The easiest method to connect the wires to the leads is to make a small hook on each, then squeeze them together. This will hold the joint while you solder.
How much slack do you need in the wires? That's up to you really. The 10 anodes will each be connecting to a perfboard or breadboard where the 100 ohm resistors are. The 5 cathodes can connect directly to the Arduino. Be sure to think for a minute how your boards will be laid out. Also make sure to give yourself plenty of slack to open and close the Lite Brite.
Connect Hookup Wires and Resistors to Perfboard
This step is relatively straightforward. Each of the 10 anode hookup wires need to connect to the perfboard, through a 100 ohm resistor, then to another hookup wire on the other side. You will also connect the anodes of each of you colons through a 100 ohm resistor.
Before you start soldering, you need to know exactly where your perfboard and Arduino will mount in the case. Once you decide on location, you will know how long to make the hookup wires.
To connect to the perfboard, just insert the wires and resistors through the top of the board. (The top of the perfboard does not have the copper pads). Twist the leads together and solder. Try to get solder on and across the pads, and not just the leads. Watch the video carefully for further instruction. Feel free to cut your perfboard down, like I did in the video. Be careful though, the perfboard is very brittle. I would cut it before I did any work in case the board gets ruined.
The first video "Breadboard Fail" can be skipped. I try to use a breadboard, which would have been faster. The hookup wire kept coming out and I decided it was too fragile. So I ripped the wires out and used a perboard instead.
Before you start soldering, you need to know exactly where your perfboard and Arduino will mount in the case. Once you decide on location, you will know how long to make the hookup wires.
To connect to the perfboard, just insert the wires and resistors through the top of the board. (The top of the perfboard does not have the copper pads). Twist the leads together and solder. Try to get solder on and across the pads, and not just the leads. Watch the video carefully for further instruction. Feel free to cut your perfboard down, like I did in the video. Be careful though, the perfboard is very brittle. I would cut it before I did any work in case the board gets ruined.
The first video "Breadboard Fail" can be skipped. I try to use a breadboard, which would have been faster. The hookup wire kept coming out and I decided it was too fragile. So I ripped the wires out and used a perboard instead.
Connect Hookup Wires to the Arduino
Carefully strip and connect the hookup wires to the Arduino. Use the chart below as a reference. For further reference, you can watch me do it in the video. Note that the cathodes for the colon are connected to ground and the anodes are connected to digital pins 10 and 11.
Preliminary Testing
Hookup a USB cable and temporarily close up the case of the Lite Brite.
I quickly wrote this code which will count from 0-9 on all digits, except for the first one of course, which will only light up when displaying a '1'.
Please excuse my un-commented code. I will come back and comment later, but it should be fairly straightforward and easy to read.
No doubt you will have a short, disconnected wire or something to sort out in this step.
int column[]={0,1,2,3,4,5,6,7,8,9,10,11,12};
int row[] = {14,15,16,17,18};
void setup()
{
for (int i=0;i<13;i++){
pinMode(column[i],OUTPUT);
digitalWrite(column[i],LOW);
}
for (int j=0;j<5;j++){
pinMode(row[j],OUTPUT);
digitalWrite(row[j],HIGH);
}
}
void loop () {
for(int x=0;x<1000;x++){
zero(0);
zero(3);
zero(6);
}
for(int x=0;x<1000;x++){
one(-3);
one(0);
one(3);
one(6);
}
for(int x=0;x<1000;x++){
two(0);
two(3);
two(6);
}
for(int x=0;x<1000;x++){
three(0);
three(3);
three(6);
}
for(int x=0;x<1000;x++){
four(0);
four(3);
four(6);
}
for(int x=0;x<1000;x++){
five(0);
five(3);
five(6);
}
for(int x=0;x<1000;x++){
six(0);
six(3);
six(6);
}
for(int x=0;x<1000;x++){
seven(0);
seven(3);
seven(6);
}
for(int x=0;x<1000;x++){
eight(0);
eight(3);
eight(6);
}
for(int x=0;x<1000;x++){
nine(0);
nine(3);
nine(6);
}
}
void allOn(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],LOW);
digitalWrite(column[y],HIGH);
}
}
}
void allOff(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],HIGH);
digitalWrite(column[y],LOW);
}
}
}
void zero(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void one(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void two(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void three(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void four(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void five(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void six(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void seven(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
}
void eight(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
}
void nine(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
I quickly wrote this code which will count from 0-9 on all digits, except for the first one of course, which will only light up when displaying a '1'.
Please excuse my un-commented code. I will come back and comment later, but it should be fairly straightforward and easy to read.
No doubt you will have a short, disconnected wire or something to sort out in this step.
int column[]={0,1,2,3,4,5,6,7,8,9,10,11,12};
int row[] = {14,15,16,17,18};
void setup()
{
for (int i=0;i<13;i++){
pinMode(column[i],OUTPUT);
digitalWrite(column[i],LOW);
}
for (int j=0;j<5;j++){
pinMode(row[j],OUTPUT);
digitalWrite(row[j],HIGH);
}
}
void loop () {
for(int x=0;x<1000;x++){
zero(0);
zero(3);
zero(6);
}
for(int x=0;x<1000;x++){
one(-3);
one(0);
one(3);
one(6);
}
for(int x=0;x<1000;x++){
two(0);
two(3);
two(6);
}
for(int x=0;x<1000;x++){
three(0);
three(3);
three(6);
}
for(int x=0;x<1000;x++){
four(0);
four(3);
four(6);
}
for(int x=0;x<1000;x++){
five(0);
five(3);
five(6);
}
for(int x=0;x<1000;x++){
six(0);
six(3);
six(6);
}
for(int x=0;x<1000;x++){
seven(0);
seven(3);
seven(6);
}
for(int x=0;x<1000;x++){
eight(0);
eight(3);
eight(6);
}
for(int x=0;x<1000;x++){
nine(0);
nine(3);
nine(6);
}
}
void allOn(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],LOW);
digitalWrite(column[y],HIGH);
}
}
}
void allOff(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],HIGH);
digitalWrite(column[y],LOW);
}
}
}
void zero(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void one(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void two(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void three(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void four(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void five(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void six(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void seven(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
}
void eight(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
}
void nine(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
The Code
Time to program the Arduino. Feel free to use the code below. You will first need to download the Time library from http://arduino.cc/playground/Code/Time . Once downloaded, you will put the Time library into the libraries folder of your Arduino directory. You will then need to go to Sketch---Import Library---Time to include the Time library in your sketch.
Here's how it works:
1. The individual LED's are turned on by setting the row of the LED to LOW, and the Column of the LED to HIGH. The trick is that only one LED can be controlled at a time. If you look at the code, you will see that as soon as an LED is turned on, it is turned off right away. This works because of our persistence of vision and because the LED's are being switched off and on at a very high rate of speed. The entire display is getting redrawn on the order of 500 times per second.
2. You will notice that I have the colon dots hooked up to two of the output pins. Why would I do this when they are always on? Good question! It's because if we don't turn the colon dots off and on at the same rate as the rest of the LED's, the colon dots would be about ten times brighter that their neighbors. I tried using constant power to the dots, and it looked terrible.
3. I wrote a function that draws each digit in the first 7 segment position. I also made the function so that it would accept an offset parameter. To write the digit in the first position, the offset is -1. The third position is +3 and the last position is +6. My code is probably pretty inefficient, but this part works well.
4. The hour is easy to parse from the timeFormat12() function of the Time.h library. The only tricky part is getting the two parts of the minutes. The first digit of the minutes can be obtained from simple integer division by 10. This will truncate the second digit and only return the ten minute portion. For example, 59/10=5 in integer division. For the second digit of the minutes, you use the mod function to return the remained after dividing by 10. Thus, 59%10 = 9.
5. I realize the clock code could have been written much more efficiently, and if someone bothers to improve it, I would love to see it done well. I did the best I could for a guy who is not an engineer or a programmer. All I can really say about my code is that it appears to work.
#include <Time.h>
int column[]={0,1,2,3,4,5,6,7,8,9,10,11};
int row[] = {14,15,16,17,18};
void setup()
{
setTime(9,27,0,27,7,2012);
for (int i=0;i<13;i++){
pinMode(column[i],OUTPUT);
digitalWrite(column[i],LOW);
}
for (int j=0;j<5;j++){
pinMode(row[j],OUTPUT);
digitalWrite(row[j],HIGH);
}
}
void loop () {
digitalWrite(column[11],HIGH);
digitalWrite(column[12],HIGH);
digitalWrite(column[11],LOW);
digitalWrite(column[12],LOW);
switch (hourFormat12()) {
case 1:
one(0);
break;
case 2:
two(0);
break;
case 3:
three(0);
break;
case 4:
four(0);
break;
case 5:
five(0);
break;
case 6:
six(0);
break;
case 7:
seven(0);
break;
case 8:
eight(0);
break;
case 9:
nine(0);
break;
case 10:
one(-3);
zero(0);
break;
case 11:
one(-3);
one(0);
break;
case 12:
one(-3);
two(0);
break;
}
switch ((minute()/10)) {
case 0:
zero(3);
break;
case 1:
one(3);
break;
case 2:
two(3);
break;
case 3:
three(3);
break;
case 4:
four(3);
break;
case 5:
five(3);
break;
}
switch (minute()%10) {
case 0:
zero(6);
break;
case 1:
one(6);
break;
case 2:
two(6);
break;
case 3:
three(6);
break;
case 4:
four(6);
break;
case 5:
five(6);
break;
case 6:
six(6);
break;
case 7:
seven(6);
break;
case 8:
eight(6);
break;
case 9:
nine(6);
break;
// if nothing else matches, do the default
// default is optional
}
}
void allOn(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],LOW);
digitalWrite(column[y],HIGH);
}
}
}
void allOff(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],HIGH);
digitalWrite(column[y],LOW);
}
}
}
void zero(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void one(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void two(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void three(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void four(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void five(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void six(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void seven(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
}
void eight(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
}
void nine(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
Here's how it works:
1. The individual LED's are turned on by setting the row of the LED to LOW, and the Column of the LED to HIGH. The trick is that only one LED can be controlled at a time. If you look at the code, you will see that as soon as an LED is turned on, it is turned off right away. This works because of our persistence of vision and because the LED's are being switched off and on at a very high rate of speed. The entire display is getting redrawn on the order of 500 times per second.
2. You will notice that I have the colon dots hooked up to two of the output pins. Why would I do this when they are always on? Good question! It's because if we don't turn the colon dots off and on at the same rate as the rest of the LED's, the colon dots would be about ten times brighter that their neighbors. I tried using constant power to the dots, and it looked terrible.
3. I wrote a function that draws each digit in the first 7 segment position. I also made the function so that it would accept an offset parameter. To write the digit in the first position, the offset is -1. The third position is +3 and the last position is +6. My code is probably pretty inefficient, but this part works well.
4. The hour is easy to parse from the timeFormat12() function of the Time.h library. The only tricky part is getting the two parts of the minutes. The first digit of the minutes can be obtained from simple integer division by 10. This will truncate the second digit and only return the ten minute portion. For example, 59/10=5 in integer division. For the second digit of the minutes, you use the mod function to return the remained after dividing by 10. Thus, 59%10 = 9.
5. I realize the clock code could have been written much more efficiently, and if someone bothers to improve it, I would love to see it done well. I did the best I could for a guy who is not an engineer or a programmer. All I can really say about my code is that it appears to work.
#include <Time.h>
int column[]={0,1,2,3,4,5,6,7,8,9,10,11};
int row[] = {14,15,16,17,18};
void setup()
{
setTime(9,27,0,27,7,2012);
for (int i=0;i<13;i++){
pinMode(column[i],OUTPUT);
digitalWrite(column[i],LOW);
}
for (int j=0;j<5;j++){
pinMode(row[j],OUTPUT);
digitalWrite(row[j],HIGH);
}
}
void loop () {
digitalWrite(column[11],HIGH);
digitalWrite(column[12],HIGH);
digitalWrite(column[11],LOW);
digitalWrite(column[12],LOW);
switch (hourFormat12()) {
case 1:
one(0);
break;
case 2:
two(0);
break;
case 3:
three(0);
break;
case 4:
four(0);
break;
case 5:
five(0);
break;
case 6:
six(0);
break;
case 7:
seven(0);
break;
case 8:
eight(0);
break;
case 9:
nine(0);
break;
case 10:
one(-3);
zero(0);
break;
case 11:
one(-3);
one(0);
break;
case 12:
one(-3);
two(0);
break;
}
switch ((minute()/10)) {
case 0:
zero(3);
break;
case 1:
one(3);
break;
case 2:
two(3);
break;
case 3:
three(3);
break;
case 4:
four(3);
break;
case 5:
five(3);
break;
}
switch (minute()%10) {
case 0:
zero(6);
break;
case 1:
one(6);
break;
case 2:
two(6);
break;
case 3:
three(6);
break;
case 4:
four(6);
break;
case 5:
five(6);
break;
case 6:
six(6);
break;
case 7:
seven(6);
break;
case 8:
eight(6);
break;
case 9:
nine(6);
break;
// if nothing else matches, do the default
// default is optional
}
}
void allOn(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],LOW);
digitalWrite(column[y],HIGH);
}
}
}
void allOff(){
for(int x=0;x<5;x++){
for(int y=0;y<13;y++){
digitalWrite(row[x],HIGH);
digitalWrite(column[y],LOW);
}
}
}
void zero(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void one(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void two(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void three(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void four(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
void five(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
}
void six(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
}
void seven(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
}
void eight(int x){
digitalWrite(column[1+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
}
void nine(int x){
digitalWrite(column[3+x],HIGH);
digitalWrite(row[0],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[0],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[1],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[1],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[1+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[1+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[2],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[2],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[3],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[3],HIGH);
digitalWrite(column[2+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[2+x],LOW);
digitalWrite(row[4],HIGH);
digitalWrite(column[3+x],HIGH);
digitalWrite(row[4],LOW);
digitalWrite(column[3+x],LOW);
digitalWrite(row[4],HIGH);
}
The Finish!
You should now have a working Lite Brite clock! You can set the time by changing the values in the line of code that says - setTime(9,27,0,27,7,2012);
Read the Time documentation at Arduino.cc, but the first two numbers of the setTime parameters are hour and minute.
You may or may not be finished with your clock yet. I attempted to run my clock from a nine volt battery - FAIL. It didn't even make it 24 hours. You will either need to use this as a computer desk clock and just leave the clock connected to the USB port of your computer, or you can connect a 7-12 volt wall wart to your board.
If I had it to do over again, I would have used multi-colored diffuse LED's...probably 8mm.
Hope you enjoyed and learned from this instructable. If any of you have questions or would like to show off your clock, please post them here.
Read the Time documentation at Arduino.cc, but the first two numbers of the setTime parameters are hour and minute.
You may or may not be finished with your clock yet. I attempted to run my clock from a nine volt battery - FAIL. It didn't even make it 24 hours. You will either need to use this as a computer desk clock and just leave the clock connected to the USB port of your computer, or you can connect a 7-12 volt wall wart to your board.
If I had it to do over again, I would have used multi-colored diffuse LED's...probably 8mm.
Hope you enjoyed and learned from this instructable. If any of you have questions or would like to show off your clock, please post them here.