Introduction: Simple Binary Count-Down to Christmas

Picture of Simple Binary Count-Down to Christmas

Wanna make a count down to Christmas?
Don't have any 8 segment LEDs?
Well you can still make a cool little count down that will have friends asking how to read it.
Using same format as a binary clock except just two digits creating a very simple count down.

Step 1: Things You'll Need

Picture of Things You'll Need

1 Arduino
6 LEDs (technically u don't need all 6 but we can pretend we're counting down from December 1st.)
Computer, to program of course.
And a source of continuous power (9V or USB phone charger will do)

Step 2: How Do I Read Binary?

Picture of How Do I Read Binary?

The way you read a binary clock is by taking each column of lights and adding up the lit rows (representing numbers) to get your digit, in our case a two digit number.
Each row is giving a number like so:
8
4
2
1
So for example my first step photo is representing 1 and 2+4 meaning 16.

You can also use this source to learn, also the source of this picture.
http://www.wikihow.com/Read-a-Binary-Clock

Step 3: Code!

So now we need code, Happly letting you guys use my code and go ahead to edit it and make it better (it can be improved).
At the top of the code you can see 3 variables: Day, Hour, and Minute, these you fill in just before you upload your code and it will start from here. 


[Start]
int Day = [DAY OF THE MONTH];
int Hour = [CURRENT HOUR IN 24 HOUR FORMAT];
int Minute = [CURRENT MINUTE IN TIME];

int DaysLeft = 25-Day;

int tensPlDL = DaysLeft/10;
int onesPlDL = DaysLeft-tensPlDL*10;
void setup() {
  
  pinMode(A5, OUTPUT);       
  pinMode(A4, OUTPUT);
 
  pinMode(A3, OUTPUT);
  pinMode(A2, OUTPUT);
 
 
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
 
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
 
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
 
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);

digitalWrite(A5, LOW);
digitalWrite(A3, LOW);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);

Serial.begin(9600);
}

void loop() {

 
  if(canTwo(tensPlDL)){
    digitalWrite(A2, HIGH);  
    tensPlDL=tensPlDL-2;
  }else{
    digitalWrite(A2, LOW);}
  if(canOne(tensPlDL)){
    digitalWrite(A4, HIGH);
  }else{
    digitalWrite(A4, LOW);}
       
  if(canEight(onesPlDL)){
    onesPlDL=onesPlDL-8;
    digitalWrite(9, HIGH);
  }else{
    digitalWrite(9, LOW);
  }
 
 
  if(canFour(onesPlDL)){
    onesPlDL=onesPlDL-4;
    digitalWrite(7, HIGH);
  }else{
    digitalWrite(7, LOW);
  }
 
  if(canTwo(onesPlDL)){
    onesPlDL=onesPlDL-2;
    digitalWrite(5, HIGH);
  }else{
    digitalWrite(5, LOW);
  }
 
  if(canOne(onesPlDL)){
    digitalWrite(3, HIGH);
  }else{
    digitalWrite(3, LOW);
  }
 
  delay(60000);
 
  Minute++;
  if(Minute==60){
  Hour++;
  Minute=0;
  }
  if(Hour==24){
  Day++;
  Hour=0;
  }
  DaysLeft = 25-Day;
  tensPlDL = DaysLeft/10;
  onesPlDL = DaysLeft-tensPlDL*10;
 
  /*
  Serial.print(tensPlDL);
  Serial.print("\t");
  Serial.print(onesPlDL);
  Serial.print("\t");
  Serial.println(DaysLeft);
  */
  if(DaysLeft==0){
  while(true){
  digitalWrite(A2, HIGH);
  digitalWrite(A4, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(3, HIGH);
  delay(500);
  digitalWrite(A2, LOW);
  digitalWrite(A4, LOW);
  digitalWrite(9, LOW);
  digitalWrite(7, LOW);
  digitalWrite(5, LOW);
  digitalWrite(3, LOW);
  delay(500); 
}
  }
}

boolean canEight(int number){
if(number-8>=0){
    return(true);
    }else{
      return(false);
      }
}

boolean canFour(int number){
if(number-4>=0){
    return(true);
    }else{
      return(false);
      }
}

boolean canTwo(int number){
  if(number-2>=0){
    return(true);
    }else{
      return(false);
      }
}

boolean canOne(int number){
  if(number-1>=0){
    return(true);
    }else{
      return(false);
      }
}
[End]

Step 4: Install LEDs

Picture of Install LEDs

Now I do have to warn you that when using an Arduino it's not in your best interest to plug LEDs directly into the Arduino, and should have a resistor to increase the life span of your LED, so you've been warned.

Pins used are:
           9
           8
           7
           6
A2      5
A3      4
A4      3
A5

Going positive negative per LED so:
9,7,5,3,A2,A4 are positive
rest are negative, REMEMBER the flat side of the LED is negative!

You can probably judge off the photo easily as well if needed.

Step 5: Upload Code!

Picture of Upload Code!

Now you got your LED's in place and how to read it once it's up and running, correct the current date and time in the code and upload, and it will continue to countdown, keep in mind you have to keep it powered or it will reset back to what you original set.

So you can either plug in a 9V (and hopefully it will last till Christmas) 
Or use a 9V to transfer to another power source other than your computer, USB charger for example.
and of course you can just leave it plugged into your computer (If you want to leave it on that long..)

Step 6: Now We Wait!

Sit back and as the days go by count down in binary to Christmas.
:D

(Also a challenge of how long you can keep an Arduino powered.)



Additional ideas:
Use Christmas color lights! I would have but I could only find red lights.
Create a nice box to store your countdown in.
Use some multiplexing to reduce number of pins.

Comments

andrea biffi (author)2013-12-10

I'm not sure about Arduino UNO, but older Arduino has the internal resistor only for pin13, so you should add a resistor for any of the other pins, otherwise you'll burn the circuit...