Project in progress
 Arduino 24h Binary Clock with Seconds (17 LEDs)

Arduino 24h Binary Clock with Seconds (17 LEDs) © GPL3+

Use your Arduino to create a Binary Clock and learn how to read Binary numbers.

  • 3,737 views
  • 8 comments
  • 17 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
09590 01
LED (generic)
I used 10 red, 6 green and 1 Orange LED.
×17
Mfr 25frf52 100r sml
Resistor 100 ohm
1 Resistor for every LED
×17

About this project

This clock does not (yet) synchronise with any time server and does not use a real time clock module to stay exactly on time (yet).

It just runs a basic seconds count with a 1000 millisecond delay in the sketch. LEDs are connected to PWM 3 to 19 with a resistor each.

Note that: PWM pins 14 to 19 are the Analog pins 0 to 5.

I will be adding Internet time synchronisation soon. Stay tuned and hit Follow! ;)

Enjoy and greetings,

Peter Lunk

24h Binary Clock with Seconds - Demo Video

Code

Arduino 24h Binary Clock with Seconds Sketch / codeArduino
// Arduino 24h Binary Clock with Seconds. (17 LEDs total)
// You can find a demonstration video of this project
// here on Youtube: https://www.youtube.com/watch?v=R1rWMhTKyh0
// Full project on Hackter.io : https://www.hackster.io/peter-lunk/arduino-24h-binary-clock-with-seconds-17-leds-total-2c2374
// Greetings, MrLunk

// pins 2 - 13 are the regular digital pwm pins.
int ledPinsSec[] = {2, 3, 4, 5, 6, 7};
int ledPinsMin[] = {8, 9, 10, 11, 12, 13};

// pins 14 - 20 are the analog pins 0 - 5 used as digital pwm pins  
int ledPinsHr[] = {14, 15, 16, 17, 18, 19};

// set Start time here
int countS = 0;   // Seconds
int countM = 13;  // Minutes
int countH = 23;  // Hours

byte countSec;
byte countMin;
byte countHr;
#define nBitsSec sizeof(ledPinsSec)/sizeof(ledPinsSec[0])
#define nBitsMin sizeof(ledPinsMin)/sizeof(ledPinsMin[0])
#define nBitsHr sizeof(ledPinsHr)/sizeof(ledPinsHr[0])

void setup(void)
{
  for (byte i = 0; i < nBitsSec; i++) {
    pinMode(ledPinsSec[i], OUTPUT);
  }

  for (byte i = 0; i < nBitsMin; i++) {
    pinMode(ledPinsMin[i], OUTPUT);
  }

  for (byte i = 0; i < nBitsHr; i++) {
    pinMode(ledPinsHr[i], OUTPUT);
  }
}

// ----- Main Routine -------------------------------------------------

void loop(void)
{
  countS = (countS + 1);
  if (countS > 59)
  {
    countS = 0;
    countM = (countM + 1);
    if (countM > 59)
    {
      countM = 0;
      countH = (countH + 1);
      if (countH > 23)
      {
        countH = 0;
        countM = 0;
        countS = 0;
      }
    }
  }

  dispBinarySec(countS);
  dispBinaryMin(countM);
  dispBinaryHr(countH);

  delay(1000);   // 1000 milliseconds = approx. 1 second delay
  // ADJUST for fast or slow running clock here, in milliseconds.
}

// ----- Subroutines ---------------------------------------------------

void dispBinarySec(byte nSec)
{
  for (byte i = 0; i < nBitsSec; i++) {
    digitalWrite(ledPinsSec[i], nSec & 1);
    nSec /= 2;
  }
}

void dispBinaryMin(byte nMin)
{
  for (byte i = 0; i < nBitsMin; i++) {
    digitalWrite(ledPinsMin[i], nMin & 1);
    nMin /= 2;
  }
}

void dispBinaryHr(byte nHr)
{
  for (byte i = 0; i < nBitsHr; i++) {
    digitalWrite(ledPinsHr[i], nHr & 1);
    nHr /= 2;
  }
}

Schematics

Arduino 24h Binary Clock with Seconds Schematics
24h binary clock with seconds arduino 8izwvkeez6

Comments

Similar projects you might like

Binary Clock

Project showcase by pdio

  • 2,110 views
  • 4 comments
  • 9 respects

Amazing Binary Clock using LED Matrix Module

Project tutorial by LAGSILVA

  • 9,775 views
  • 12 comments
  • 55 respects

Sensal - All Senses Alarm Clock

Project in progress by Leonid Piliptsevich

  • 8,784 views
  • 2 comments
  • 28 respects

Digital And Binary Clock With Two LED Matrix And RTC

Project tutorial by LAGSILVA

  • 6,133 views
  • 10 comments
  • 27 respects

Binary Clock with Arduino and Plywood

Project tutorial by Kalle Wallin

  • 3,329 views
  • 1 comment
  • 10 respects

Motion Detector Clock

Project in progress by Frazer Reid

  • 1,893 views
  • 0 comments
  • 3 respects
Add projectSign up / Login