Nerd Pocket Watch

36,543

258

22

Jack passed away May 20, 2018 after a long battle with cancer. His Instructables site will be kep...

Intro: Nerd Pocket Watch

This is my entry for the Remix 2.0 contest. It is based on the Nerd Watch instructable by othermachine. If you like this please vote for me.

I liked the idea of the original instructable, but I have not yet started etching my own printed circuit boards and my old eyes don't see well enough to solder SMD parts. I built this on a Perma Proto board from Adafruit that is designed to fit into a small Altoids tin, and to use all through hole parts.

You will need:

(Note) This resistor kit from Sparkfun gives you a total of 500 resistors, 25 each of many common sizes:

https://www.sparkfun.com/products/10969

.

You will also need a way to program the ATtiny85 chip the Tiny AVR Programmer

from Sparkfun is a good choice. The directions for installation and use are here:

https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/

There are many other options available to program the chip, just search instructables for "ATtiny".

Step 1: Assembly

Cut a piece of the bubble wrap to fit in the bottom of the Altoids tin. This is to prevent shorts.

Build the circuit according to the schematic.

The numbers on the outside of the box representing the chip are the physical pin numbers, and the digital pin numbers are listed inside the box.

Step 2: The Program

Download this program and put it on your ATtiny85.

You can change the value in the line that says

long calibrate = 313250; // Five minutes.

to make your watch run faster or slower. There is some variation in the ATtiny internal clock. It usually tends to run a little bit fast. The calibration is the value for my particular chip.

/************************************************************
 * Digital nerd watch program
 *
 * Original program by othermachine on instructables.com
 *
 * Re-programmed by JRV31
 *
 ************************************************************/

  int greenLED = 1;         // Pin for green LED.
  int yellowLED  = 4;       // Pin for yellow LED.
  int button = 0;           // Pin for pushbutton switch.

  int blinkDelay = 350;     // Length of blink in milleseconds.

  long calibrate = 313250;  // Five minutes. 

  long starttime;
  
  int hour = 0;
  int minute = 0;

/************************************************************
 * setup() function - required
 ************************************************************/
void setup()
{
  pinMode(greenLED, OUTPUT);     // Set LED pins to output.
  pinMode(yellowLED, OUTPUT);
  pinMode(button, INPUT_PULLUP); // Set button pin to input with pullup
  digitalWrite(yellowLED, HIGH); // Initial state of LEDs is off.  
  digitalWrite(greenLED, HIGH);   

  settime();                     // function to set the time.

  starttime = millis();          // Mark starting time.
  while((millis()-starttime)<(calibrate/2)) // Wait 2 1/2 minutes before 
                                            // advancing time for the first time.
  {                                         
    if(digitalRead(button)==LOW)            // Displaying time works
    {                                       // during first 2 1/2 minutes.
      displaytime(hour);
      delay(blinkDelay*3);
      displaytime(minute);
    }
  }

  starttime = millis();         // 2 1/2 minuter have go by.  
  minute++;                     // Advance the time.
  if(minute==12) hour++;
  if(minute>12)
  {
    minute = 1;
    if(hour>12) hour = 1;
  }
}

/************************************************************
 * loop() function - required
 ************************************************************/
void loop()
{
  if((millis()-starttime)>calibrate) // Advance time every 5 minutes.
  {
    starttime = millis();
    minute++;
    if(minute==12) hour++;
    if(minute>12)
    {
      minute = 1;
      if(hour>12) hour = 1;
    }
  }  

  if(digitalRead(button)==LOW) // Display time if button pressed.
  {
    displaytime(hour);
    delay(blinkDelay*3);
    displaytime(minute);
  }
}

/*****************************************************************
 * settime() function called by setup() to set the clock at start.
 *****************************************************************/
void settime()
{
  int i;

  delay(3000);                          // Wait three seconds after start.
  i=0;
  while(i==0)
  {  
    digitalWrite(greenLED, LOW);        // Green LED blinks, 
    starttime = millis(); 
    while((millis()-starttime)<500)     // count the blinks and
    {
      if(digitalRead(button)==LOW) i++; // press the button when
    }
    digitalWrite(greenLED, HIGH);       // count equals hour hand. 
    starttime = millis(); 
    while((millis()-starttime)<500)
    {
      if(digitalRead(button)==LOW) i++;
    }
    hour++;
  }  

  delay(3000); // Wait 3 seconds between hour and minute.
  i=0;
  while(i==0)
  {  
    digitalWrite(yellowLED, LOW);        // Yellow LED blinks,
    starttime = millis(); 
    while((millis()-starttime)<500)      // count the blinks
    {
      if(digitalRead(button)==LOW) i++;  // press the button when
    }
    digitalWrite(yellowLED, HIGH);       // count equals minute hand. 
    starttime = millis(); 
    while((millis()-starttime)<500)
    {
      if(digitalRead(button)==LOW) i++;
    }
    minute++;
  }  

  if(hour>11) hour = 11;              // Set hour to 11 and minute 
  if(minute>12) minute = 12;
  if(hour==0) hour = 11;              // to 12 if over or zero. 
  if(minute==0) minute =12;

  while(digitalRead(button)==HIGH);   // Wait for button press to start.
  while(digitalRead(button)==LOW);    // debounce
}

/************************************************************
 * displaytime() function displays the time.
 ************************************************************/
void displaytime(int hhmm)
{
  if(hhmm>7)               // If number to display is > 7
  { 
    blinker(greenLED);     // blink green LED and
    hhmm-=8;               // subtract eight.
  }
  else blinker(yellowLED); // else blink yellow LED.
        
  if(hhmm>3)
  { 
    blinker(greenLED);
    hhmm-=4;
  }
  else blinker(yellowLED);
        
  if(hhmm>1)
  { 
    blinker(greenLED);
    hhmm-=2;
  }
  else blinker(yellowLED);
     
  if(hhmm==1)
  { 
    blinker(greenLED);
  }
  else blinker(yellowLED);
}     

/************************************************************
 * blinker() blinks one LED once.
 ************************************************************/
void blinker(int LED)
{
  digitalWrite(LED, LOW);  // Turn LED on.
  delay(blinkDelay);
  digitalWrite(LED, HIGH); // Turn LED off.
  delay(blinkDelay);
}

Step 3: Using the Nerd Pocket Watch

Every time you start your Nerd Pocket Watch the first thing you do is set the time.

When you turn it on with the toggle switch there is a short pause then the green LED starts blinking.

Count the blinks and press the pushbutton switch when it has blinked the right number of times needed to represent the hour hand on an analog clock.

Example: If the hour hand should be on six let it blink six times then push the button.

There is another short pause then the yellow LED starts blinking.

Again count the blinks and press the button when it has flashed the number of times for the minute hand.

Press the button one more time and nothing happens. The time is now set and the watch is running.

.

Now every time you press the button it will give you the time in a binary format, first the hour hand and then short pause then the minute hand.

The green light is a one and the yellow light is a zero.

Example: It flashes Yellow Green Green yellow, that is 0110. in binary that is six.

4 People Made This Project!

Recommendations

  • Audio Contest 2018

    Audio Contest 2018
  • Optics Contest

    Optics Contest
  • Electronics Tips & Tricks Challenge

    Electronics Tips & Tricks Challenge

22 Discussions

0
None
ronw5

2 years ago

hi, I get an error when compiling the sketch. it says "button, input_pullup" is not declared. if I change the button to just "input", it compiles but then the leds make no sense. I made the nerdwatch and designed the board and 3d printer file to make a case

2 replies
0
None
dpeachronw5

Reply 2 years ago

I had the same problem, but I don't remember what fixed it. I am new to programming AVR chips, but I think the problem was that this is Arduino code and I was trying to compile it as if it were regular C code. Hopefully that points you in the right direction.

0
None
ronw5dpeach

Reply 2 years ago

maybe "compile" is the wrong word. i get the error message when I try to verify the sketch in the arduino ide. would appreciate any help. i notice that I get don't get the error if I select "uno" as the board instead of "attiny85".?????

0
None
dpeach

2 years ago

Thanks for this writeup. Mine seems to be working, but in reverse. My lights are on all the time and blink off when I think they should be off and blinking on. I haven't modified the code. Any hints?

4 replies
0
None
JRV31dpeach

Reply 2 years ago

I have the LEDs wired with the cathodes to the pins and the anodes connected to positive. The LED lights when the pin is low. This is not the normal way to wire them, but I wanted the circuit to be identical to the original.

0
None
dpeachJRV31

Reply 2 years ago

That helps. Thanks. While I read the schematic and see that it clearly says what you did, I went on what made sense when I built it. I am still on a breadboard until my IC socket arrives in the mail. So I can swap things around tonight and see how it works. I appreciate your reply.

0
None
JRV31dpeach

Reply 2 years ago

Glad to help, send me an "I made it" when you are finished.

0
None
dpeachJRV31

Reply 2 years ago

That took care of the LEDs. I will be glad to post a picture when I am done. Hopefully the final part will arrive in less than a week and I will complete this.

0
None
Makeoscopy

2 years ago

I actually wanted to put one of these into a pocket watch case I have, but ended up favoring a watch design. The original watch project had a code that wouldn't compile, but yours works like a charm! Thank you!

0
None
JRV31

2 years ago

I would like to thank whoever posted a link to this instructable. It got over 11000 hits in one day.

0
None
qdogg

3 years ago on Step 3

How about hooking up a MC14028B BCD to decimal decoder. Would that allow someone to count the blink without the think? Maybe that would make it less nerdy but easier all the way around.

0
None
Phil_S

3 years ago on Introduction

Nice to see ? something by a fellow old eyes type.

I love these little 8-pin devices and I am presently migrating to Tiny's from Arduino.

Long live DIP-8. Alternatively, stock-up now before Atmel pulls the plug.

A clock where you have to do the sums? - better than crossword puzzles.

1 reply
0
None
JRV31Phil_S

Reply 3 years ago on Introduction

I hope Atmel doesn't pull the plug. I know they are increasing production on the SMD part. I also know Atmel was just sold to some British company.

0
None
JRV31

3 years ago on Introduction

If you like this please vote for it in the Remix 2.0 contest.

0
None
JRV31I dont wanna go

Reply 3 years ago on Introduction

Hurry up and make it, the Remix 2.0 contest ends 9/21/15.

It would be interesting to see a re-remix.

0
None
I dont wanna goJRV31

Reply 3 years ago on Introduction

Oh I wouldn't want to compete with yours! Already voted for this! I'll put pictures of mine in the comment section or the "I Made it" section if I do build one.