Project showcase
Binary Wristwatch

Binary Wristwatch © Apache-2.0

A wristwatch that displays time in binary through an array of LEDs.

  • 1,246 views
  • 0 comments
  • 11 respects

Components and supplies

Necessary tools and machines

3drag
3D Printer (generic)
Having friends that own 3D printers is handy dandy.
09507 01
Soldering iron (generic)
I use a Hakko-FX888D

Apps and online services

About this project

When searching through my future college's engineering videos, one of them stated at the beginning of the video, "It is likely students have made their own projects, perhaps by following other people's tutorials, but it is very likely they haven't completed the design of a project from beginning to end by themselves."

This sparked a challenge. I had 8 months before college...I could do this! The year previous, I saw a binary watch sold on a German website...and instead of spending $30 to buy one, why not spend $100 to make my own?

And thus my binary watch project was born.

The barebones ATmega328P is the brains of the watch, powered by a LiPo battery. The ATmega328P sends signals to the 74HC595 shift registers, which then output the "time" to the LEDs. I used a 32.768kHz clock for keeping real time, and the low-power ATmega sleep modes to preserve as much power as possible.

I started by breadboarding a mock circuit with the ESP32 as the brains.

Then I switched to the Arduino Uno:

Next a barebones ATmega328P-PU with a 16MHz clock:

Finally, I ended up with the barebones ATmgea328P and a 32.768kHz clock.

To follow my debugging and developing process more in-depth, you can visit my blog, on these posts:

Basis: https://thalliatree.wordpress.com/2017/12/25/74hc595-texas-instruments-shift-registers/

Intro: https://thalliatree.wordpress.com/2018/01/01/project-hype-binary-wristwatch/

Breadboard Hardware (with Uno): https://thalliatree.wordpress.com/2018/01/26/atmega328p-microcontroller-74hc595-shift-register-setup-and-test-binary-watch/

Code - Part 1: https://thalliatree.wordpress.com/2018/01/29/code-part-1-binary-watch/

Code - Part 2: https://thalliatree.wordpress.com/2018/01/31/code-part-2-binary-watch/

Breadboard Hardware (without Uno): https://thalliatree.wordpress.com/2018/02/04/prepping-the-atmega328p-bootloader-burn-fuse-byte-programming-and-hardware-test-binary-watch/

Mock Up PCB with coin cells + early schematic: https://thalliatree.wordpress.com/2018/02/05/mock-up-pcb-binary-watch/

Code - Part 3: https://thalliatree.wordpress.com/2018/03/16/code-part-3-binary-watch/

Atmega328p 32.768kHz, sleep modes, and new schematic: https://thalliatree.wordpress.com/2018/03/26/atmega328p-32-768khz-sleep-modes-and-new-schematic-binary-watch/

Final Code, Schematic, and PCB layout: https://thalliatree.wordpress.com/2018/04/03/final-code-schematic-and-pcb-binary-watch/

PCB 95% Complete: https://thalliatree.wordpress.com/2018/05/03/pcb-95-complete-binary-watch/

Finale: https://thalliatree.wordpress.com/2018/05/14/binary-watch-complete/

Code

bwatch-clock.cppC/C++
/*
*
* written by: thallia
* date: 3-14-18
* last edit: 3-31-18
* Specifically only using the 32kHz clock, adjusting the hardware to fit it.
*
*/
#include <avr/sleep.h>
#include <avr/power.h>

const int inDisplay = 2;  // display button
const int inHour = 6;     // hour button
const int inMinute = 7;   // minute button

const int outputEN = 0;   // enable chip signal
const int clockP = 1;     // clock signal pin
const int latchP = 4;     // latch signal pin
const int dataP = 5;      // data write pin

// Default date/time settings whenever program starts
int seconD = 0;
int minutE = 0;
int houR = 1;
int halfDay = 1;

int checkDisplay = 0;

// interrupt on Timer 2 compare "A" completion - does nothing
EMPTY_INTERRUPT (TIMER2_COMPA_vect);

// Boolean --> Void / pin signal
// If true, enableOutput writes an ON signal to the OE gate, allowing LED output
// if false, enableOutput writes OFF signal to the OE gate.
void enableOutput(boolean state){
  if(state){
    digitalWrite(outputEN, LOW); // OE is NOTed, which is why we write LOW to
                                 // trigger a HIGH signal.
  } else{
    digitalWrite(outputEN, HIGH);
  }
}

void latchTick(){
  digitalWrite(latchP, HIGH);
  digitalWrite(latchP, LOW);
  digitalWrite(clockP, HIGH); // turns the clock on
  digitalWrite(clockP, LOW); // turns clock off
}

// Integer --> Void / Pin Signal
// writeData writes the new data to the dataPin.
void writeData(){
  digitalWrite(dataP, HIGH);
  latchTick();
  digitalWrite(dataP, LOW);
}

// No input --> No output
// checkHour checks if the hourButton has been pressed. If true, increase
// the LED output.
void checkHour(){
  int hourButton = digitalRead(inHour);
  if(hourButton == LOW){
    houR++;
    seconD = 0;
  }
}

// no input --> no output
// check minute checks if the minButton has been pressed. If true, increase
// the min LED output.
void checkMin(){
  int minButton = digitalRead(inMinute);
  if(minButton == LOW){
    minutE++;
    seconD = 0;
  }
}

// Integer --> LED signal (hours)
// writes to the hour display
void hourDisplay(int houR){
  if(houR >= 1){
    for (int x = 3; x >= 0; x--){
      int bit = bitRead(houR, x);
        if(bit == 1){
          writeData();
        } else {
          latchTick();
       }
    }
  }
}

// integer --> LED signal (minutes)
// writes to the minute display
void minDisplay(int minutE){
  for(int x = 5; x >= 0; x--){
    int bit = bitRead(minutE, x);
    if(bit == 1){
      writeData();
    } else {
      latchTick();
    }
  }
}

// integer --> void
// AmPm makes sure that we see regular time, not military time.
void ampm(int state){
  if(state >= 1){
    writeData();
  } else {
    latchTick();
  }
}

/* ------------------------------------------------------------------------- */

void setup()
 {

   pinMode(clockP, OUTPUT);
   pinMode(outputEN, OUTPUT);
   pinMode(latchP, OUTPUT);
   pinMode(dataP, OUTPUT);

   pinMode(inHour, INPUT_PULLUP);
   pinMode(inMinute, INPUT_PULLUP);
   pinMode(inDisplay, INPUT_PULLUP);

  // clock input to timer 2 from XTAL1/XTAL2
  ASSR = bit (AS2);

  // set up timer 2 to count up to 32 * 1024  (32768)
  // timer counts to 32*1024 which takes 1 sec, then triggers interrupt
  TCCR2A = bit (WGM21);                             // CTC
  TCCR2B = bit (CS20) | bit (CS21) | bit (CS22);    // Prescaler of 1024
  OCR2A =  31;              // count to 32 (zero-relative)

  // enable timer interrupts
  TIMSK2 |= bit (OCIE2A);

  // disable ADC
  ADCSRA = 0;

  // turn off everything we can
  power_adc_disable();
  power_spi_disable();
  power_twi_disable();
  power_timer0_disable();
  power_timer1_disable();
  power_usart0_disable();

  // full power-down doesn't respond to Timer 2
  set_sleep_mode(SLEEP_MODE_PWR_SAVE);

  // get ready ...
  sleep_enable();

  }  // end of setup

void loop()
  {
  enableOutput(false);

  // turn off brown-out enable in software
  MCUCR = bit(BODS) | bit(BODSE);
  MCUCR = bit(BODS);

  // sleep, finally!
  sleep_cpu();

  // we awoke! pulse the clock hand
  // digitalWrite(tick, ! digitalRead(tick));
  seconD++;
  // one minute every 60sec
  if(seconD >= 59){
    minutE++;
    seconD = 0;
  }

  // one hour every 60min
  if(minutE >= 59){
    houR++;
    minutE = 0;
  }

  // halfDay every 12hrs
  if(houR >= 13){
    halfDay++;
    houR = 1;
    minutE = 1;
  }

  // reset AM/PM
  if(halfDay >= 2){
    halfDay = 0;
    houR = 1;
    minutE = 0;
  }

  checkHour();
  checkMin();

  checkDisplay = digitalRead(inDisplay);
  if (checkDisplay == LOW){
    ampm(halfDay);
    minDisplay(minutE);
    hourDisplay(houR);
    latchTick();
    enableOutput(true);
  }
}  // end of loop: loop back, sleep, wake up after 1 second
Binary Watch
Working code is in the /src directory.

Custom parts and enclosures

binary watch base
Binary watch lid

Schematics

Binary Watch Schematic
Bw schematic nndhnlit0o

Comments

Similar projects you might like

3-Bit Binary Calculator Using Arduino Uno

Project showcase by 22warehamD

  • 3,242 views
  • 8 comments
  • 12 respects

ATmega Alien Themed Slot Machine

Project tutorial by Dan Murphy

  • 1,081 views
  • 5 comments
  • 14 respects

Standalone Arduino Applied in Projects

Project tutorial by PCBWay and Silícios Lab

  • 5,601 views
  • 8 comments
  • 40 respects

What to Wear? Twitter Button

Project showcase by Arduino “having11” Guy

  • 2,799 views
  • 0 comments
  • 6 respects

Guitar Speed Pick and Stomp Pedal!

Project tutorial by marc_uberstein

  • 5,088 views
  • 8 comments
  • 30 respects

Personal Home Assistant

Project tutorial by 3 developers

  • 4,597 views
  • 0 comments
  • 29 respects
Add projectSign up / Login