Introduction: 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.

Comments

author
ronw5 made it! (author)2016-01-15

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

author
dpeach made it! (author)dpeach2016-01-16

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.

author
ronw5 made it! (author)ronw52016-01-18

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".?????

author
ronw5 made it! (author)2016-01-17

any help on the error I'm getting. I would really like to make this work. I will share my pcb and 3d print files. thanks.

nerd_pocketwatch.jpg
author
dpeach made it! (author)2016-01-16

I prototyped the watch on a breadboard first. The only component that came from the breadboard to the final project was the ATtiny85.

The next 2 pictures show the buildup and the 4th picture is the wiring on the bottom. I wanted the watch to sit a little higher in the case so I added some blobs of hot glue. I had to sand them down a little to get them level.

The then last picture is the finished project from the top.

I chose to go with 2 green LEDs for two reasons. It makes the whole thing even more cryptic to someone who doesn't know my layout. And the biggest reason is that I didn't have 2 different colors of the same size LEDs. I have multiple colors but none of the packaging matches.

1prototype1.png2buildup1.png3buildup2.png4buildup3.png5bottom.png6top.png
author
dpeach made it! (author)2016-01-10

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?

author
JRV31 made it! (author)JRV312016-01-12

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.

author
dpeach made it! (author)dpeach2016-01-13

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.

author
JRV31 made it! (author)JRV312016-01-13

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

author
dpeach made it! (author)dpeach2016-01-13

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.

author
Makeoscopy made it! (author)2015-12-16

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!

author
SimonF9 made it! (author)2015-11-14

great little gadget to confuse my family and some of my friends as none of them is able to read binary ^^

temp_1615892327.jpg
author
JRV31 made it! (author)2015-11-02

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

author
qdogg made it! (author)2015-09-28

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.

author
Phil_S made it! (author)2015-09-27

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.

author
JRV31 made it! (author)JRV312015-09-28

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.

author
mitchell.maxberry made it! (author)2015-09-27

If I build it do I get a trip to the White House ?

author
JRV31 made it! (author)JRV312015-09-28

You will have to ask Mr. Obama about that.

author
Stenkryparen made it! (author)2015-09-27

Nice, and weary nerdy! I will try it on my Arduino nano.

author
JRV31 made it! (author)2015-09-23

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

author
pieterg made it! (author)2015-09-11

i actually like this better than the original one. it has more mystery when using it. Please show the tin on the outside!

author
JRV31 made it! (author)JRV312015-09-11

Here it is

Altoids.png
author
pieterg made it! (author)pieterg2015-09-13

nice! Really finishes it! thnx!

author
I dont wanna go made it! (author)2015-09-11

Great project! Planning on making my own with some mods ;)

author
JRV31 made it! (author)JRV312015-09-12

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

It would be interesting to see a re-remix.

author
I dont wanna go made it! (author)I dont wanna go2015-09-12

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.

author
PRO DR MR BOB made it! (author)2015-09-11

nice will make when my attiny comes in! (got it and didnt know a project for it)

author
JRV31 made it! (author)JRV312015-09-11

The ATtiny is a really fun chip, check out my ATtiny collection here:

https://www.instructables.com/id/Attiny85-and-84-projects-and-tutorials/

About This Instructable

35,634views

255favorites

License:

Bio: Most of my instructables will be tutorials for Atmel microcontrollers, Arduino, or Raspberrypi. I try to show concepts that you can use in your own ... More »
More by JRV31:MoonLight7400 Quad Nand Gate SimulationRaspberryPi: set-up WIFI in Jessie-Lite
Add instructable to: