## My Doctor Who MonoChron Clock

Tick Tock Clock Kits

### My Doctor Who MonoChron Clock

I am working on a Doctor Who inspired clock for the MonoChron. A video can be seen here. http://youtu.be/DHecR3Matss

The TARTIS travels through an wiggly wormhole. Pressing a button or switch (except "Menu") will cause the TARTIS to dematerialize and rematerialize a moment later in a random spot. My daughter plans on using this as her primary alarm clock once I figure out how to replace the alarm siren with the Doctor Who theme song.

I had to rewrite the wormhole code a few times to get it fast enough render correctly. The GLCD.h drawing routines are way too slow instead the wormhole uses glcdDataWrite()s directly to draw everything.

To speed things up I also EXTERMINATEd all division and modulus operations. For example to separate the hour into a high digit and low digit:

Code: Select all
`high_digit = hour/10;low_digit = hour%10;`

I found this to be much faster

Code: Select all
`high_digit = 0;low_digit = hour;while (low_digit >= 10) {  // Count tens  high_digit++;  low_digit -= 10;}`

When you have as much motion as this clock does every clock cycle counts.
DanSlage

Posts: 3
Joined: Thu Jan 26, 2012 3:29 pm

### Re: My Doctor Who MonoChron Clock

Nice one! You should post this in this thead too:

Posts: 16644
Joined: Sat Feb 07, 2009 9:11 am

### Re: My Doctor Who MonoChron Clock

What datatype is "hour"?

This is good up to 99:
Code: Select all
`high_digit = 0;low_digit = something;if (low_digit >= 60) {high_digit += 6; low_digit -= 60;}if (low_digit >= 30) {high_digit += 3; low_digit -= 30;}if (low_digit >= 20) {high_digit += 2; low_digit -= 20;}if (low_digit >= 10) {high_digit += 1; low_digit -= 10;}`
odometer

Posts: 97
Joined: Sun Aug 21, 2011 10:01 pm

### Re: My Doctor Who MonoChron Clock

Nice Odometer! The datatype is uint8_t but never goes larger than 59 in my program. My gut tells me your code would be faster than mine. I wonder if anyone has ever done any speed trials.
DanSlage

Posts: 3
Joined: Thu Jan 26, 2012 3:29 pm

### Re: My Doctor Who MonoChron Clock

I hate to be "that guy" but... It's TARDIS! (Time and Relative Dimension in Space)

Nicodemus_NJ

Posts: 1
Joined: Wed Apr 27, 2011 10:36 am

### Re: My Doctor Who MonoChron Clock

DanSlage wrote:I am working on a Doctor Who inspired clock for the MonoChron. A video can be seen here. http://youtu.be/DHecR3Matss

My daughter plans on using this as her primary alarm clock once I figure out how to replace the alarm siren with the Doctor Who theme song.

Sounds like you need to interface a wave shield to the clock some how.

kscharf

Posts: 136
Joined: Wed Sep 10, 2008 9:29 am

### Re: My Doctor Who MonoChron Clock

Hi-

We did a Dr. Who song through a piezo speaker an on Arduino. I used an existing program for the piezo frequencies and sound generation, which I have forgotten and can't attribute, sorry! We only figured out the melody and the timing.

Code: Select all
`const int  b=     4056;    // 261 Hz const int  c=     3830;    // 261 Hz const int  d=     3400;    // 294 Hz const int  e=     3038;    // 329 Hz const int  f=     2864;    // 349 Hz const int  g=     2550;    // 392 Hz const int  a=     2272;    // 440 Hz const int  B=     2028;    // 493 Hz const int  C=     1912;    // 523 Hz const int  D=     1700;    // 523 Hz const int  E=     1508;    // 523 Hz const int  F=     1432;    // 523 Hz const int  G=     1278;    // 523 Hz const int  A=     1136;    // 523 Hz // Define a special note, 'R', to represent a restconst int  R=     0;int speakerOut = 13;int melody[] = { b,  C,  B,  D,  a,  B,  B, g,  d,  b,  d, c, b,R } ;int beats[]  = { 8,  8, 48,  8,  8, 64,  8, 8,  8,  8, 16, 16,16,96 } ; int MAX_COUNT = 14; // Melody length, for looping.// Set overall tempolong tempo = 10000;// Set length of pause between notesint pause = 1000;int rest_count = 100; //<-BLETCHEROUS HACK; See NOTESfor(int js=0; js<20; js++) {   for (int i=0; i<MAX_COUNT; i++) {    tone_ = melody[i];    beat = 4*beats[i];    duration = beat * tempo; // Set up timing    playTone();     // A pause between notes...    delayMicroseconds(pause);   }}void playTone() {  long elapsed_time = 0;  if (tone_ > 0) { // if this isn't a Rest beat, while the tone has     //  played less long than 'duration', pulse speaker HIGH and LOW    while (elapsed_time < duration) {      digitalWrite(speakerOut,HIGH);      delayMicroseconds(tone_ / 2);      // DOWN      digitalWrite(speakerOut, LOW);      delayMicroseconds(tone_ / 2);      // Keep track of how long we pulsed      elapsed_time += (tone_);    }   }  else { // Rest beat; loop times delay    for (int j = 0; j < rest_count; j++) { // See NOTE on rest_count      delayMicroseconds(duration);      }                                  }                                 }`
JakeS

Posts: 10
Joined: Tue Feb 22, 2011 11:15 am

### Re: My Doctor Who MonoChron Clock

I second using the piezo to just play the theme, it sounds good on Tesla coils so a piezo should be fine too