Landline phone conversation recorder for Windows 10

Phone Recorder is an application for Windows 10
that allows you to join and record an ongoing telephone
conversation.  It runs under either 64-bit or 32-bit Windows.  
Phone Recorder doesn't have much of a user interface — just
two buttons: "Start recording/Stop recording" and "Exit".  
When you click on "Start recording", Phone Recorder will join
an ongoing phone conversation on the same line as that of the
modem, and the button label will change to "Stop recording".  
The conversation is stored as a .wav file in the same folder
as the Phone Recorder executable (.exe) file.  To run Phone
Recorder, you need to have a dial-up modem that has voice
capability installed on your computer.  Phone Recorder uses
only the voice feature of the modem — there's no need to
"dial-up" anywhere.  Be sure to tell the other party or
parties on the line that you are recording the conversation
if it is legally required to do so.

Here's a link to the Phone Recorder app kit:
https://dl.dropboxusercontent.com/u/97098121/Phone%20Recorder%20Kit.zip
 

Gamma wave meditation aid

I built a circuit that flashes a 6 by 6 array of LED lights at
40 Hz (40 flashes per second).  This 40 Hz frequency
stimulates the brain to strengthen the level gamma waves
that it normally produces at that frequency.  This is said to
have a calming effect on your mood and to generate a sense
of well-being.  And is said to be an aid to meditation.  Also,
a 40 Hz flashing LED array, might alleviate the symptoms of
Alzheimer's disease, a small study has suggested.
Here is a link to the circuit:
https://www.keepandshare.com/doc6/18658/40hz-circuit-pdf-240k?da=y

The LED array I use in the circuit is this product on Amazon:
https://www.amazon.com/gp/product/B01IAMVU30/ref=oh_aui_detailpage_o05_s00?ie=UTF8&psc=1

You could power it with a power bank, external battery for
charging smartphones. There are many of these on Amazon.
Also you could power it with a 5 volt voltage-regulated wall wart.
 

 

Linear Regression: Least Squares Fit of a Straight Line to a Set of Points. Includes a Proof that the Total Variance can be Divided into Component Parts, and also Includes a Derivation of the Correlation Coefficient, Explaining its Meaning

We want to fit a straight line of the form:

(Eq. 1) or, alternatively,

(Eq. 2) to a set of data points.
 

Using the least squares method, we want to minimize the function:

(Eq. 3).

Taking partial derivatives and setting them to zero, we get:

(Eq. 4).

(Eq. 5).

Solving these equations, we get:

(Eq. 6), and

(Eq. 7),

or, (Eq. 8). 

In the following, we will assume that the number of points, n, in our data set is
quite large, say, >= 100. 
So to calculate variances we will simply divide sums
by n (rather than n-1 or n-2 to take into account degrees of freedom). 
Consequently, the variances we will calculate are only close approximations.

Using the values of a and b that we calculated above to minimize the F function,
we have:

So,
(Eq. 9),

where is the part of the total variance, that is left unexplained by the regression. 

The other part of the total variance is variance explained by the regression,
The explained and unexplained variances should add up to the total variance, i.e., that

(Eq. 10), and we will now prove that. 

Equation 10 can also be written as:

                                                           

We start the proof with:

  (identity). 

Squaring both sides and summing, we get:

. 

So the theorem is true if: 
.

Or equivalently if:

(Eq. 11).

            (A)                       (B)

From Equation 4, since we are using the optimum values for a and b, we know that:

, and, substituting for , that means that

is zero. So (B) above is true. 
From equation 5, we know that . Substituting , we get:

Simplifying, we get: ,

 

and:

. Since (B) , above, is zero, that means that (D) is zero,

           (C)                            (D)

 

which in turn means that (C) is zero. And (C) is the same as (A), so (A) is zero. 
Then, because (A) and (B) are both zero, equation 11 is zero. This proves
equation 10, that:

, i.e., that the total variance can be separated into two
non-overlapping components, the variance explained and the variance
unexplained by the regression, that added together are equal to the total variance.

Now we will look at the relationship between the total variance and the unexplained variance and define a correlation coefficient, r.

Squaring equation 1, , we get: .

Summing over n yields: , which means that

. 

Substituting for in Equation 10, we have

, or


A standard equation for the variance of a sample is:
.

And since, from equation 6,
, then

 

, or

The rightmost term on the right hand side of this equation is the square of the correlation coefficient, r.

So, (Eq. 12). 

From equation 10, we know that , or .

Substituting into equation 12, . 

So,

In words, is the ratio of the variance explained by the regression of Y on X to the total variance. This, in my opinion provides a better definition of the correlation coefficient than its usual definition as .

 

 

Cow Grazing in a Circular Pasture Problem: Solution by Calculus

"A cow is attached by a rope to a point on the perimeter 
of a circular field. How long should the rope be in terms 
of the radius of the field so that the cow can graze in 
exactly half of the field?"

This problem has been around in one form or another 
for a long time.  You can find many solutions to it 
on on the internet.  But all of the solutions I've seen 
are geometric solutions, using plane geometry.  They 
all chop up the pasture into various shapes and add up 
the area of each one.

I have found a solution using calculus that I think is 
a lot simpler and more elegant.  This solution defines 
a differential of area that is centered around the point 
on the perimeter of the pasture where one end of the 
rope is tied.  Then it integrates from the origin (zero) 
until the rope is long enough to allow the cow to graze 
on half the area of the circular pasture.  
Here's the derivation:

Let R be the radius of the cow pasture.
Let r be the length of the rope.
Let Θ be the angle between a line from the point where 
the rope is tied on the perimeter of the pasture to the 
center of the pasture, and a line of length r from where
the rope is tied on the perimeter to the edge of the 
pasture.  See diagram: 

                

1. BC is a circular arc of radius r centered at point A.  
   The length L of BC is 2Θr.
2. Cos(Θ) = AB/AD = r/(2R), so Θ = cos-1(r/(2R)).
   (Note: Angle ABD is a right angle because it intercepts
   a 180 degree arc.)
3. So L = 2Θr = 2r * cos-1(r/(2R)).
4. Consequently, one form of a differential of area of
   the pasture is dArea = 2r * cos-1(r/(2R))dr.

We want to integrate this differential along AC starting 
at point A until r is long enough so that half the area
of the pasture is enclosed, so we need to solve for x:

Wolfram’s online integrator, integrals.wolfram.com, easily solves 
the integral portion of this equation if you substitute K for R 
in the integral.  Then you can let R = 1 and use WolframAlpha to 
solve for the ratio of r to R that will result in half of the 
area of the pasture.  The answer, to 4 decimal places is 
r = R * 1.1587

About Butterscotch and How to Make Butterscotch Flavor Powder

About Butterscotch
      My sources for this are many Google searches about butterscotch on the internet. 
First, there is no such thing as "true butterscotch".  The many recipes I found have various
ratios of sugar to butter, and there is a variation in the ingredients.  So there is only
"version A" of butterscotch, "version B", "version C" and so on.  The commonality
among most of them is that they contain sugar, butter, salt, and molasses.  The sugar
can be light brown sugar, dark brown sugar, or just plain sugar.  If it's just plain sugar,
molasses is added to the recipe; otherwise, molasses is optional.  If molasses is added
it can be plain molasses or, occasionally, blackstrap molasses.  The sugar to butter
ratio varies greatly — anywhere from 4:3 to 16:1 by weight, I've read.

The sugar, butter, salt, and molasses are mixed together and cooked until the temperature
is raised to anywhere between 245 degrees F to 310 degrees F. 

One question I asked myself is why, if molasses is just mostly caramelized sugar (as many
sources on the internet say), why, if it's added separately, is it always cooked along with the
other ingredients and not added later?  After further research on the internet, I found the
answer: Molasses is NOT caramelized sugar!  Why?  To refine sugar, sugar cane is boiled in
a vacuum at 160 degrees F.  160 degrees F is well below the caramelization temperature of
sugar, which begins at about 320 degrees F.  Also at 160 degrees F the Maillard reaction
(which I'll get to shortly) is very slow, so molasses has undergone very little Maillard reaction.

Caramelization is not important for butterscotch because butterscotch is not caramelized, but
the Maillard reaction is very important since it is what develops the butterscotch flavor.  The
Maillard reaction takes place at an optimal rate between 270 and 310 degrees F.  To avoid

caramelization from occurring, among all but one of the recipes  I've seen for butterscotch,
the maximum cooking temperature is 300 degees F.

How to Make Butterscotch Flavor Powder
      I like the flavor of butterscotch a lot, and after some experimenting I figured out how to
make a butterscotch flavor powder that I could add to other things, such as yogurt.  The
following recipe is based on recipes for butterscotch I've found on the internet, plus a
couple of my own ideas, which seem to be original.

Ingredients
60 grams      dark brown sugar

30 grams      unsalted butter
1/8 tsp          salt (not sea salt)

1 1/2 Tbsp    blackstrap molasses (optional, to make the flavor "extra butterscotchy")
2 tsp             water (approximarely)

Cooking 
      Mix the ingredients together in a pan, adding just enough water to wet down the
other ingredients, set a stovetop burner in the medium heat range, and, stirring 
constantly, cook slowly until the temperature of the mixture is a carefully measured
310 to 315 degrees F.  Cooking slowly is important for giving the Maillard reaction time
to take place. (The Maillard reaction is what develops the butterscotch flavor.)  For
measuring the temperature, I use an infrared surface temperature thermometer. 
There are many brands of these infrared thermometers on Amazon.

When the mixture is cooked, pour it immediately (not letting it harden) onto a flat
surface that has been covered with a sheet of parchment paper, and let the mixture
cool for, say, 20 minutes, until it is rock solid.  Then crack it up with your food-gloved
hands, transfer it to a blade type coffee grinder, and grind it into a fine powder.  This
may require several "transfer-grind" operations.  Store the powder in a refrigerator,
and use it as desired.  When using the powder, also add some vanilla flavor or extract.

Serving size 1 Tbsp.  Makes about 7 servings.
 

“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:

              
https://www.keepandshare.com/doc6/18671/knock-knock-unlock-box-open-jpg-65k?da=y
 

              
https://www.keepandshare.com/doc6/18668/knock-knock-unlock-box-closed-jpg-50k?da=y


PARTS
    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

CONNECTIONS
    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

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

    Servo
        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.

ARDUINO CODE
    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

  http://creativecommons.org/licenses/by-nc-sa/3.0/
 
This source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#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);
servo.attach(servo_control);
delay(1000);

servo.write(CLOSED_ANGLE);
delay(1000);

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;
  servo.write(OPEN_ANGLE);
  delay(7000);
  servo.write(CLOSED_ANGLE);
  delay(1000);
  digitalWrite(off_pin, HIGH);     // Turn off the power.
  }
else
  {
  if (knock_count < knocksToOpen)
       {
       servo.write(CLOSED_ANGLE);
       delay(1000);
       }
  }

while(1)
  {
  knockOkFlag = 1;                 // Allow reception of knocks.
  delay(250);
  ++delay_count;
  if (delay_count >= 120)          // If 30 seconds have passed since starting,
    {
    digitalWrite(buzz_pin, HIGH);  // send a long buzz and
    delay(600);
    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;
    ++knock_count;
    }

  if (knock_count >= knocksToOpen)
    {
    break;
    }
  } // 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.
  }

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:
https://www.keepandshare.com/doc6/18670/runs-test-for-randomness-zip-3k?da=y

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

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:

https://www.keepandshare.com/doc6/18672/geiger-counter-circuit-v3-jpg-172k?da=y

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:

https://www.keepandshare.com/doc6/18673/geiger-counter-lcd-display-ino-4k?da=y

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

Description
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:
https://dl.dropboxusercontent.com/u/97098121/Call%20Screener%20v4.01%20Agere%20version%20Kit.zip