Binary clock counting pulses

Hello y'all, I'm making a binary clock and I am in the need for some assistance. I am using Arduino UNO and I have the time patch installed in the library of UNO. At the moment, I have 7 led's for seconds, 7 led's for minuets, and 6 led's for hours. I am also using 2 led's to indicate AM or PM also another 2 led's that are under constant illumination to light up a backdrop. All led's are supplied with a 5v feed through a parallel circuit style design,each led is connected to a 220 OHM resistor and when instructed to by UNO it was pulled low and illuminated the led. As of right now I have a sample program counting to 255 on each of the 22 leds. The circuit hardware is working as designed now I am just missing the brains of the operation. How do I start to write the code for this? What should I research? Do I have programmer level access to the 16 MHZ clock on the chip, if so, in that case can I just divide the 16MHZ by X to get "1 clock pulse per second" to use as my time reference? Would I run this in a loop or at an initial setup? Please advise...

At the moment, I have 7 led's for seconds

0...59 only needs 6 LEDs

and I have the time patch installed in the library of UNO.

What does this mean? What patch to what library?

How do I start to write the code for this?

First, you need to be able to get the time. Can you do that? Then, you need to convert the time to a value to display for hours, minutes, seconds, etc. Do you know how to do that?

correction: It is 6 LED'S for seconds,7 for Minutes, and 7 for hours. According to the arduino website " The Time library adds timekeeping functionality to Arduino with or without external timekeeping hardware. It allows a sketch to get the time and date as: second, minute, hour, day, month and year. It also provides time as a standard C time_t so elapsed times can be easily calculated and time values shared across different platforms." Arduino Playground - HomePage. I do not know how to convert the time to a display, the idea was to have run a counter in a loop cycle and pull the instructed pins low by declaring them beforehand.

I do not know how to convert the time to a display

I'm not sure what problems you are having, because, despite this being the programming forum you haven't posted any code.

The time library provides most of the conversion tools you need. It can break a time variable into hours, minutes, and seconds. It can tell you whether the time is AM or PM.

What else do you need to know? Using the value for hours, for instance, is going to be very dependent on the hardware that you have (specifically, with how it is connected to the Arduino). If you can display any value from 0 to 255 on the hour LEDs, I don't see what is difficult about displaying a specific value. The same holds true for minutes and seconds.

Ha, I have no code wrote so far. I had copied the 255 off the ARDUINO website it was strictly to see if the hardware was functioning as designed. I don't know how or where to start, for I have very minimal experience.

I don't know how or where to start, for I have very minimal experience.

Welcome. Congrats on starting with existing code and learning the GUI environment.
Your next step is to use the Forum Search or Google to look for representative code that assists you with something you are interested... If clocks, great, as there is a huge volume of material.

When you find your skeleton framework, start the customization ... Delete what you do not want, compiling/Verifying between each surgery. Save intermediate code using something like _01, _02, _03, etc.

Then start working on adding the new code. Again, use Forum Search and Google first and rely upon forum posts for roadblocks.

Good luck on your voyage,

Ray

correction: It is 6 LED'S for seconds,7 for Minutes, and 7 for hours.

I don't understand the logic there; if it is six for seconds (60 per minute) then it is also six for minutes (60 per hour) and five for hours (either 24 hour, or 12 hour plus am/pm indicator)

I currently have a code for the binary clock based on the same formula of LEDS and outputs I have. It's not making any sense HA. The clock is counting incorrectly. The only working code that I can see working correctly is the 0-255 on 7 leds. @ AWOL I don't understand your question,--> http://www.google.com/imgres?imgurl=http://www.instructables.com/files/deriv/FM9/WVOH/GU09UNRA/FM9WVOHGU09UNRA.MEDIUM.jpg&imgrefurl=http://www.instructables.com/id/My-Arduino-Binary-Clock/&h=412&w=620&sz=18&tbnid=Rw39gUEq_zUFkM:&tbnh=90&tbnw=135&prev=/search%3Fq%3Darduino%2Bbinary%2Bclock%26tbm%3Disch%26tbo%3Du&zoom=1&q=arduino+binary+clock&usg=__oeJRkiTtaHjcASt_hdrTlEZla70=&docid=7jnBdy2j4djiNM&sa=X&ei=mcskUrz_HtS54AOtwoG4Dw&sqi=2&ved=0CDwQ9QEwAg&dur=430 <--. This is a sample of the circuit design I am using except add seconds in exactly replicating the minuets column. Where can I start to understand how to write this.

The only working code that I can see working correctly is the 0-255 on 7 leds

How does that work?

Each led represent a piece of binary information, with momentary on's and off visually displaying the number shown by the code.(8BITS) think of 255, a combination of 1+2+4+8+16+32+64+128= 255, 128 displayed would be 1 2 4 8 16 32 64. So everything tied to the individual led is pulled low to complete the individual led circuit when instructed to by the clocks code.

it would be 8 leds not 7

I know how binary works, which is why I know that 0..59 can be represented by just six LEDs, and 0..23 with just five.

I don't know, I guess this looks better?

Jeez....H...Chr....

For everybody else, here is the code from the instructible he is trying to use --

/*
An open-source binary clock for Arduino. 
*/

int second=0, minute=0, hour=0; //start the time on 00:00:00
int munit = 0;
int hunit = 0;
int valm=0;
int valh=0;
int ledstats = 0;
int i= 0;
boolean light = 1;

void setup() { //set outputs and inputs
pinMode(0, OUTPUT);
pinMode(1, 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);pinMode(10, OUTPUT);
pinMode(11, OUTPUT);pinMode(12, OUTPUT);pinMode(13, OUTPUT);

pinMode(18, INPUT);
pinMode(14, INPUT);
pinMode(19, INPUT);
digitalWrite(14, HIGH);
digitalWrite(19, HIGH);
digitalWrite(18, HIGH);
}


void loop() {
digitalWrite(0, HIGH);
static unsigned long lastTick = 0; // set up a local variable to hold the last time we moved forward one second
// (static variables are initialized once and keep their values between function calls)
// move forward one second every 1000 milliseconds

if (millis() - lastTick >= 1000) {
  lastTick = millis();
  second++;

}

// move forward one minute every 60 seconds
  if (second >= 60) {
  minute++;
  second = 0; // reset seconds to zero
}

// move forward one hour every 60 minutes
if (minute >=60) {
  hour++;
  minute = 0; // reset minutes to zero
}

if (hour >=24) {
  hour=0;
  minute = 0; // reset minutes to zero
}

  munit = minute%10; //sets the variable munit and hunit for the unit digits
  hunit = hour%10;


  ledstats = digitalRead(18);  // read input value, for setting leds off, but keeping count
  if (ledstats == LOW){
    light=!light;
    delay(250);
  }
    
    if(light== LOW){
  for(i=1;i<=13;i++){
  digitalWrite(i, HIGH);}
  
  } else  {

  //minutes units
  if(munit == 1 || munit == 3 || munit == 5 || munit == 7 || munit == 9) {  digitalWrite(1, LOW);} else {  digitalWrite(1, HIGH);}
  if(munit == 2 || munit == 3 || munit == 6 || munit == 7) {digitalWrite(2, LOW);} else {digitalWrite(2,HIGH);}
  if(munit == 4 || munit == 5 || munit == 6 || munit == 7) {digitalWrite(3, LOW);} else {digitalWrite(3,HIGH);}
  if(munit == 8 || munit == 9) {digitalWrite(4, LOW);} else {digitalWrite(4,HIGH);}

  //minutes 
  if((minute >= 10 && minute < 20) || (minute >= 30 && minute < 40) || (minute >= 50 && minute < 60))  {digitalWrite(5, LOW);} else {digitalWrite(5,HIGH);}
  if(minute >= 20 && minute < 40)  {digitalWrite(6, LOW);} else {digitalWrite(6,HIGH);}
  if(minute >= 40 && minute < 60) {digitalWrite(7, LOW);} else {digitalWrite(7,HIGH);}

  //hour units
  if(hunit == 1 || hunit == 3 || hunit == 5 || hunit == 7 || hunit == 9) {digitalWrite(8, LOW);} else {digitalWrite(8,HIGH);}
  if(hunit == 2 || hunit == 3 || hunit == 6 || hunit == 7) {digitalWrite(9, LOW);} else {digitalWrite(9,HIGH);}
  if(hunit == 4 || hunit == 5 || hunit == 6 || hunit == 7) {digitalWrite(10, LOW);} else {digitalWrite(10,HIGH);}
  if(hunit == 8 || hunit == 9) {digitalWrite(11, LOW);} else {digitalWrite(11,HIGH);}

  //hour
  if(hour >= 10 && hour < 20)  {digitalWrite(12, LOW);} else {digitalWrite(12,HIGH);}
  if(hour >= 20 && hour < 24)  {digitalWrite(13, LOW);} else {digitalWrite(13,HIGH);}

  }

  valm = digitalRead(14);    // add one minute when pressed
   if(valm== LOW) {
   minute++;
   second=0;
   delay(250);
  }
  
  valh = digitalRead(19);    // add one hour when pressed
   if(valh==LOW) {
   hour++;
   second=0;
   delay(250);
  }


}

Okay, so....Mikey, is this the code you tried?

HOW is it "counting wrong"??

What do you EXPECT it to do?
What IS it doing?
How did you set the time?

Is this how you have it connected to Arduino??

LED1-LED2-LED3-LED4 to ARDUINO DIGITALS PIN1-PIN2-PIN3-PIN4
units of Minutes

LED5-LED6-LED7 to ARDUINO DIGITALS PIN5-PIN6-PIN7
tens of Minutes

LED8-LED9-LED10-LED11 to ARDUINO DIGITALS PIN8-PIN9-PIN10-PIN11
units on Hours

LED12-LED13 to ARDUINO DIGITALS PIN12-PIN13
tens of Hours

LED14/LED15/LED16/LED17/LED18/LED19/LED20/LED21/LED22/LED23/LED24/LED25/LED26/LED27/LED28
to ARDUINO DIGITAL PIN 0 (all toghether)

MICRO BUTTON
As you read above we will have 3 micro button.
1th Button will change minutes, adding one for each time you press it. ANALOG PIN 0
2th Button will change hours, adding one for each time you press it. ANALOG PIN 5
3th Button (optional) will turn ON/OFF the clock LEDs, but keep counting the time. ANALOG PIN 4

OMG,
I'm at the age where even LCD numbers have to be 1 inch high! If I had to squint and try to see just 1 of a group of blurred LEDs I would just as soon not care about the time. Even if I could see them, I am not sure I can get enough neurons to cooperate to decode the binary to "real" time.

Ray

mrburnette:
OMG,
I'm at the age where even LCD numbers have to be 1 inch high! If I had to squint and try to see just 1 of a group of blurred LEDs I would just as soon not care about the time. Even if I could see them, I am not sure I can get enough neurons to cooperate to decode the binary to "real" time.

Ray

Yep! If I were to make anything like this, it would be purely to mess with anyone else whom might see it. Or....maybe as a "gift" to someone? They'd feel obligated to keep it up & use it, but woud have to instantly explain to everyone what it is and how it works. ]:smiley: