“Knock Knock Unlock” Puzzle Box

This is my version of a "knock knock unlock" puzzle box.  A knock knock unlock puzzle box is a locked box that is opened by knocking on it with a particular sequence of knocks, for example "knock-pause-knock-knock-pause-knock-knock-knock" There are several versions of these boxes on the internet.  For my version, I wanted to make a box that has nothing mounted on the outside — no lights, no switches, no wires going through the box, and no outside latch.  Just a blank box on the outside.  Here are photos of and links to photos the inside and the outside of the box:



    1. Mini Pushbutton Power Switch, LV (Pololu #2808) – 3.95
    2. Mercury Tilt Switch, 1A @ 250V (Amazon) – $2.37
    3. Pololu 5V Step-Up/Step-Down voltage regulator (Pololu #2123) – $5.95
    4. Pololu A-Star 32U4 Micro microcontroller (Pololu #3101) – $12.75
    5. Anycubic Microphone Sound Detection Sensor Module (Amazon) – 6.99
    6. Hitec 35485S HS-5485HB Digital Servo (Amazon) – 24.84
    7. Micro Vibration Motor With Cable, 1.5V to 6V (Amazon) – $8.69
    8. 470 uF, 35VDC Capacitor (RadioShack #272-1030) – $1.49
    9. 1000 uF, 35VDC Capacitor (RadioShack #272-1032) – $1.99
    10. Safety 1st Spring-Loaded Cabinet & Drawer Latch (Walmart) – $3.59
    11. Pololu 3-AA Battery Holder (Pololu #142) – $0.99
    12. Breadboard (Sparkfun #PRT-12625) – $5.95
    13. Three Alkaline or Lithium size AA Batteries
    14. ArtMinds Wooden Box, 8 1/2" L, 5 5/16" W, 3 9/16" H (Michaels crafts) – $5.49

    Mini Pushbutton Power Switch
        VIN to 4.5V battery pack
        VOUT to voltage regulator, VIN
        A to mercury switch
        B to mercury switch
        OFF to 32U4, pin 12
        GND to common ground

    Mercury switch
        To A and B on the pushbutton power switch
        (Note: The mercury switch is mounted vertically, with the
         tip down and the connection wires above.)

    Voltage regulator
        VIN to power switch, VOUT
        VOUT to 5V common positive
        GND to common ground

    32U4 Micro microcontroller
        5V to 5V common positive
        GND to common ground
        Pin 3 to microphone DO pin
        Pin 5 to servo signal wire
        Pin 9 to vibration motor red (+) wire
        Pin 12 power switch OFF

        + to 5V common positive
        G to common ground
        DO to 32U4 pin 3

        Black to common ground
        Red to 5V common positive
        Signal wire to 32U4 pin 5

    Vibration Motor
        Red to 32U4 pin 9
        Black to common ground

    470 uF Capacitor
        Positive to 5V common positive
        Negative to common ground

    1000 uF Capacitor
        Positive to voltage regulator VIN
        Negative to common ground

    Cabinet & Drawer Latch
        1. Trim the top of the latch off so it will fit in the box.
        2. Drill a couple of 1/16" holes into the arm of the latch.
        3. Loop heavy sewing thread through the 1/16" holes and
            the servo arm and tie the servo to the latch.

    The following is just a very basic program to receive knocks and open and close
the box.  You start the program by turning the box upside down, closing the mercury
switch, and then turning the box upright.  The sequence of knocks required to open
the box is just four knocks within 30 seconds.  Add your own code to make the
required sequence of knocks more complex.

This software was written by Bob Day.
It was written in May, 2016.

This software is licensed under the terms of the Creative
Commons "Attribution Non-Commercial Share Alike" license, version
3.0, which grants the limited right to use or modify it NON-
COMMERCIALLY, so long as appropriate credit is given and
derivative works are licensed under the IDENTICAL TERMS.  For
license details see

This source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of

#include <avr/sleep.h>
#include <avr/power.h>
#include <Servo.h>
// #include <SoftwareSerial.h>
// #include <serial.h>

        // Pin assignments
static const int servo_control = 5;
static const int knock_interrupt_pin = 3;
static const int off_pin = 12;
static const int buzz_pin = 9;

        // These values should be adjusted according to your needs
static const int OPEN_ANGLE = 120;  // degrees
static const int CLOSED_ANGLE = 60; // degrees
int knocksToOpen = 4;

        // The basic objects needed
Servo servo;
volatile long knock_heard = 0;
volatile long knockOkFlag = 0;
int knock_count = 0;
int delay_count = 0;
int idx; // Index variable.
int len;
int blinkLed = 13;

// The Arduino setup() function
void setup()
pinMode(servo_control, OUTPUT);
pinMode(3, INPUT);
pinMode(off_pin, OUTPUT);
pinMode(buzz_pin, OUTPUT);

attachInterrupt(0, knock_detected, RISING);


knock_count = 0;
knock_heard = 0;
knockOkFlag = 0;
delay_count = 0;
} // End of setup().

void loop()
if (knock_count >= knocksToOpen)
  knock_count = 0;
  knock_heard = 0;
  knockOkFlag = 0;
  digitalWrite(off_pin, HIGH);     // Turn off the power.
  if (knock_count < knocksToOpen)

  knockOkFlag = 1;                 // Allow reception of knocks.
  if (delay_count >= 120)          // If 30 seconds have passed since starting,
    digitalWrite(buzz_pin, HIGH);  // send a long buzz and
    digitalWrite(buzz_pin, LOW);
    digitalWrite(off_pin, HIGH);   // turn off the power.

  knockOkFlag = 0;                 // Knocks not allowed.
  digitalWrite(blinkLed, LOW);     // Turn off the blink LED.
  if (knock_heard == 1)
    digitalWrite(buzz_pin, HIGH);  // Acknowledge the knock.
    delay(250);                    //         "
    digitalWrite(buzz_pin, LOW);   //         "
    knock_heard = 0;

  if (knock_count >= knocksToOpen)
  } // End of while(1).
} // End of loop().

// Functions

// Knock detected interrupt
void knock_detected()
  if (knockOkFlag == 1)           // If knocks are OK,
    knock_heard = 1;              // A knock was heard.
    digitalWrite(blinkLed, HIGH); // Turn on the blink LED.

  knockOkFlag = 0;                // Knocks are not OK for a while.

Program to read data from a TrueRNG V2 or a TrueRNG V3 — Source Code

I couldn't find decent source code on the internet to read data from
a TrueRNG V2 random number generating device, so I wrote my own. 
It's intended for Windows Visual Studio, but it may be adaptable to
non-Windows platforms.  I hope you find it useful.  It also works for
a TrueRNG V3.  Here's a link:


Runs Up and Down Test for Randomness — Source Code

I recently searched long and hard on the internet for source code in C language to do a runs up and down test on a sequence of numbers to test whether it was a sequence of random numbers.  I found very little.  The couple of programs had, to me, very opaque and incomprehensible code.  So I wrote my own code.  Here is a link to my C language source code:

I hope it is comprehensible to others — I've included quite a few comments in  the code to try to make it so.  The download consists of a C++ program (actually it's just C) for doing the test and an error function.  Both are intended for Windows Visual Studio, but the test program should be very easily adaptable to other platforms.  The error function might take more doing and it might be best to replace it with your own.

Geiger Counter

Update – December 20, 2018.  I added a new feature.  If you connect a, say, 3.5 volt, LED light between pin 6 on the A-Star 32U4 and ground, the LED light will flash a high radiation level warning if ever the counts per minute is 100 or greater — on for a second  then off for a second continuously, until the geiger counter is turned off.  You could also use a buzzer instead of a LED light.  End of update.

I'm quiet happy with the Geiger counter I recently built.  I found many of the ideas for the electronic circuit I used on the internet, and I added some of my own ideas that significantly improved what I found on the internet.  Here is a link to the circuit:


I connect the output of the circuit to an interrupt input of an Arduino Micro microcontroller.  What I like about the circuit is that for every alpha, beta or gamma particle the Geiger tube detects, the circuit sends a single, very clean, pulse about four microseconds wide to the microcontroller, so that each particle detection is counted once and only once.  That is in contrast with many other circuits I tried that often count a particle detection multiple times.

Currently I'm using an LND 7313 Geiger tube (which, except for the style of its connectors, is the same as the more common 7317) instead of the LND 712 that I used originally.  The 7313 is a lot more sensitive to radiation than the 712.  It also runs at 550 volts, but R7 should be 4.7 megohms instead of 10 megohms.  The circuit should also run higher voltage tubes — it can easily be adjusted to provide more that 1000 volts.

For the MCU (microcontroller), I'm using a Pololu A-Star 32U4 Micro (item #3101), which is Arduino compatible.

For a display, I use a serial 20×4 LCD display, a sparkfun #LCD-09568.

The power supply consists of three 1.5v batteries in series connected to an adjustable step-up/step-down voltage regulator (pololu item #2118) adjusted to have a 5 volt output.

These four components, the Geiger counter circuit, the MCU, the LCD display, and the 5 volt power supply share a common ground, which I'll refer to as "GND".  The positive output of the power supply I'll call "POS".  POS is also common among the components.

The connections among the components are as follows:

From the Geiger counter circuit: Vcc 5V and Vcc go to POS, "to MCU interrupt" goes to pin 3 on the MCU, and ground goes to GND.

From the LCD display: RX goes to pin 2 on the MCU, VDD goes to POS, and GND goes to GND.

From the MCU (for the connections not previously listed): the 5V pin goes to POS, and the GND pin goes to GND.

Here is a link to the program I use in the Arduino Micro:


Call Screener v4.01 for Agere or LSI or Lucent Chipset Modems – Updated for Windows 10

Call Screener v4.01 is a software app for 32 or 64 bit Windows 7, 8, 8.1 or 10 that blocks unwanted phone calls on a landline phone.  Call Screener requires a dial-up modem that has voice and caller ID capability to be installed on your computer. (Call Screener uses only the voice and caller ID features of the modem — there is no need to “dial-up” anywhere.) When a call is blocked, Call Screener speaks the message contained in the ZapMessage.wav file to the caller. An example ZapMessage.wav file is included in the kit that comes in the download. Also, if you block anonymous calls, Call Screener plays an anonymous caller rejection message that instructs the caller how to remove their call blocking.  Optionally, you can specify a different “call blocked” message for each phone number that is to be blocked.  Documentation is also included in the kit. In addition to being able to block calls by caller number, Call Screener can also block calls by caller name, such as “Card Services” or “800 Service”, no matter what number appears on the caller ID.

Call Screener v4.01 includes the latest features of Call Screener v4, including:

●  The ability to gather from the internet the most complained about annoying callers and to automatically include them in the user’s call blocking list.

●  A button on its user interface to initiate reporting of Do Not Call List violations to the National Do Not Call Registry.

●  Call blocking by caller name as well as by caller number.  Blocking by caller name makes it easy to block all calls from, for example, “800 Service” or “Card Services”, no matter what number appears on the caller ID.

●  A “black list” of caller numbers or names to be blocked.  An individual blocking message can be associated with each number or name.  You are free to create your own blocking messages and to include them in Call Screener.  In addition to caller numbers and caller names you enter, the black list can optionally include blocking of anonymous calls, “out of area” calls, “unavailable” calls, and calls for which no caller ID is received.

●  A “white list” of numbers that are always accepted.  One use of the white list is to include particular numbers from, for example, “800 Service” if you otherwise block those calls.

●  The ability to provide a comment notation in the call block list to the right of a blocked caller number or caller name, which makes the list more compact and easier to comprehend in a single glance.

Changes for version 4.01
New feature: Ability to block all calls except for those on the Accept Always list.
Bug fix: Fixed the Accept Always bug.

Suggested Modems
Modems that I’ve tried and have worked well are the HiRO H50113 USB and the Rosewill RNX-56USB-AG external modems, and the HiRO H50006 and the Rosewill RNX-56AG PCI internal modems. I think the TRENDnet TFM-560U USB external modem may also work, but since I haven’t actually tried one, I can’t vouch for it. I’ve included drivers in the kit that support both caller ID and voice for the HiRO H50113 and H50006 modems.  NOTE: The Rosewill RNX-56USB modem will not work with Call Screener. I have read that there is a bug in Microsoft’s TAPI that prevents outgoing messages from being played when used with modems that have Conexant chipsets, such as the RNX-56USB.

Here’s a link to the Call Screener v4 kit:

Minus Times Minus Equals Plus

Here’s an example I like of a negative number times another
negative number equaling a positive number:

I have been giving away five dollars each minute.
Currently, at time t = 0, I have zero dollars, but I am continuing
to give away five dollars each minute in the form of IOU’s.
Thus, the equation for the number of dollars I have at time t is
D = -5t, where D represents dollars.

Using that equation, calculate how many dollars I had four
minutes ago.


by Bob Day
Copyright (C) June, 2012 by Bob Day. All rights reserved.

Time is weird.  Maybe not as weird as consciousness, but definitely weird.  But there are some simple things we can observe about time.  First, it seems to be the property of our universe that provides the capacity for change. Without this capacity, things could not change.  We see a car moving.  "Now" it's at one spot.  A little bit "later" it has moved a little farther down the road.  Without time it couldn't do that — it would remain frozen in place.  Question: Does time always involve motion?  I think maybe it does.  Suppose we're listening to music.  The sound is changing.  The sound is a sensation in our heads, and apparently not moving.  But what causes the sound is atoms vibrating — moving back and forth — in the air.  So sound requires motion to make it.  I'm pretty sure it's all like that — same thing with a leaf changing colors: chemical reactions are involved, and, consequently, motion of atoms.  Maybe you can think of a counterexample — an example of some kind of change that doesn't involve the motion of something.

Here's another weird thing about time: It seems to go at the same rate for everything.  The definition of one second is this: "The second is the duration of 9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the cesium 133 atom (at 0 degrees K)."  OK, we have a stopwatch and we'll clock our cesium 133 atom.  We time one second on our watch and count.  Sure enough — 9,192,631,770 periods!  Let's do it again.  We get the same thing, 9,192,631,770 periods.  So time went at the same rate in each of our measurements.  But wait — that's our definition of time: whenever the cesium 133 atom makes 9,192,631,770 transitions, that's one second, no matter how long it takes.  So our first measurement might have taken a second, and the second measurement, 100 years.  Except that, if that were the case, our stopwatch (and everything else) would have had to slow down too.  That's what I meant when I said that time, apparently, goes at the same rate for everything.  And if that rate changes, it changes for everything at once.

So, as far as we can measure, time seems to flow at the same rate for everything, at least in our neck of the universe.  But who is to say that time might not flow at a different rate in a chunk of space (in our same relativistic frame) a zillion or so light years away from us?  The immediate consequence of that might be that the speed of light in that chunk of space would be different from our speed of light.  Possible?  I couldn't say either way.  But, as far as I know, there is no rule that says the flow rate of time has to be a constant throughout the universe.


Vitamins for the Mind

                               The 4:00 Meeting
Tom and Bill are standing at two places on a straight road.  Tom starts
walking toward Bill and arrives at Bill’s original place 11 minutes after
Bill had left.  At perhaps a different time, Bill starts walking toward Tom
and arrives at Tom’s original place 15 minutes after Tom had left.  When
each reaches the other’s original place, he immediately turns and starts
back, and they meet in the center at 4:00.  Assuming that they walked at
constant rates, when did each start to travel on the road?

                          Alice Forgets Her Purse
On her way out of Macys, Alice walks down a down-moving escalator
in 50 steps.  When she reaches the bottom, she suddenly remembers
she forgot her purse, and she turns and runs back up the escalator in
125 steps, stepping five times as fast as she went down.  How many steps
are on the surface of the escalator?

                               The Twelve Coins
You have 12 coins.  They are identical, except that one of them is either
heavier or lighter than the rest.  In three weighings on a balance scale, find
the odd coin and whether it’s heavier or lighter.

Consciousness Totally Explained and Elucidated

Consciousness Totally Explained and Elucidated

Copyright (C) April, 2012 by Bob Day.
All rights reserved.

Like I have even a clue.  I don't think anyone does.  But I do have some thoughts about it.  Here's the definition I'm using: "Consciousness" — that mysterious phenomenon by virtue of which we can say "I" in our minds.

1. First off, you've gotta wonder why consciousness is even necessary — why it's useful from the standpoint of evolution; that is, what survival benefit does it confer?  From a survival point of view, why wouldn't we do equally well just receiving and reacting to stimuli in a totally automatic sort of way? — like we assume a computer does.  It could be a pretty complex path between the stimulus and the reaction — for example, a computer can play an excellent game of chess, but it's still completely automatic and "mindless".  I have no clue on this point.  But "Nature" does seem to have gone to quite a bit of effort surrounding its implementation of consciousness — it's given us an elaborate internal "display screen", or in Microsoft Windows terminology, an internal "desktop", that allows us to speak with ourselves internally, to see images in our minds, and to "think".  So, obviously, there is an evolutionary benefit to incorporating consciousness into the design of creatures over a purely automatic, reactive design.  Or is there?  Anyway, my own suspicion is that consciousness is just a cheap solution to an evolutionary problem.

2. Questions without answers.  Suppose we took a person's brain out of their head, took the brain apart, cell by cell, neuron by neuron, put it back together again, and put it back into the person's head.  Would the person have consciousness?  Would he or she be the same person with the original consciousness (whatever that might mean) ?

Suppose we took a person's brain apart, and duplicated it cell for cell.  Then we put the duplicate brain back into the person's head.  Would the person have consciousness?  Would he or she be the same person?

Suppose we put the original brain into one body and the duplicate brain into another?

Suppose we took a persons brain apart, duplicated it cell for cell with semiconductor chips, and hooked up the semiconductor brain into the person's body?

3. Suggestion for an experiment.  I thought about the idea of two people having duplicate brains a little bit more, and I can imagine one result being that they would share a consciousness. (Note – I'm got going so far as to say that this is a real possibility — that's why I used the word 'imagine'.)  Going a little further, maybe creatures get consciousness somewhat analogously to how a radio receives a radio signal.  Maybe we are all tuned to some kind of central source of consciousness.  Maybe each of us is tuned to a different "frequency" of that central source, with the result that each of us has a separate consciousness.  So maybe if two people have exactly duplicate brains, they are both tuned to the same "frequency", and thus share a consciousness. (It's my blog, so I can take these flights of fancy!)

There's just a smidgeon of evidence that this is a possibility: Many sets of identical twins say that that they have a sense of one another.  One can sense when the other is in danger, can feel the other's emotions, can "feel the other's pain".  Perhaps the brains of identical twins are tuned very close to the same "frequency", so their consciousness overlaps to a degree.  As far as I know there is no good experimental evidence for this.  In fact, as of April 2012, James Randi's million dollar prize for reliably demonstrating any kind of paranormal phenomena has gone unclaimed for 14 years.  The evidence, such as it is, is all anecdotal.  That doesn't mean it's worthless, but it does mean we're not on solid ground.

My idea for an experiment is to nail down what I said in the previous paragraph, one way or the other.  Get some cloned pairs of mice that are as close to being exact duplicates as possible.  Then take one mouse of each pair, give it a little electric shock, and see whether there is any reaction from the other one in the pair.  Or, teach one mouse in each pair to run a maze, and then see whether the other mouse in the pair can learn the maze faster.  Of course, we have to have all the usual experimental controls: mice in each pair separated; a control group of mice, etc, etc.