Binary Clock - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Binary Clock

304Maverick304Maverick WVPosts: 1Member

Hello, Was wondering if anybody could help. I'm trying to code a binary clock for a project at school and I'm hitting a wall with the time delay code needed. My setup is 11 LED lights (6 for minutes, 4 four hours, one for am/pm hooked up to an 8051 microcontroller) I can use C or Assembly, but I've been working more with C lately and am fairly knowledgeable of it. Also any ideas for the input code to set the time will be great, haven't really had much time to mess with that aspect yet. Thanks in advanced


  • tienkhoanguyentienkhoanguyen houPosts: 158Member

    Well, to give you an idea of what I am thinking. There are 16 colors in Borland Turbo C 2.01 compiler. So you could use that. As far as hooking it up to your 8051 microcontroller, you could probably do that also in assembly. Borland Turbo C 2.01 allows you to insert assembly code where speed or electronics stuffs is necessary. I am not sure how it is done. However, I think you will have fun with it. Just google, "Borland Turbo C 2.01" it is free. If you need a time delay code, try this:

    int main() { int delay, count;

    delay = 12000; DELAYloop:; if (delay > 1) { delay--; }

    return 0; }

    Anyways, that is the delay. C is so fast that you need like maybe delay to be hundreds of thousands or even million to pause a second.

    If you do use a longer delay, you may need to change the int to a long

  • tienkhoanguyentienkhoanguyen houPosts: 158Member

    I forgot to add a goto DELAYloop; at the end of delay--;

  • tienkhoanguyentienkhoanguyen houPosts: 158Member

    I had a lot of help learning along the way and I am still learning so do not think you are cheating if you ask questions.

  • 304Maverick304Maverick WVPosts: 1Member

    Thank you so much, this has been more immersive that I thought it would be.

  • tienkhoanguyentienkhoanguyen houPosts: 158Member

    Jesus Christ!hehe You are welcome. I am grateful to your replies. I know assembly language can be tedious and tough especially having to know all the registers; however it gives exact control over your microcontroller. C does "not" have that specific machine interaction. C is only a superficial language. In the brief times that I have programmed C and assembly language, I notice that about each.

Sign In or Register to comment.