Introduction: The Godot Machine

What is a Godot Machine?

It is part of the human experience that we can find ourselves in a state of waiting for something that might eventually happen after a long time of waiting, or not at all.

The Godot Machine is a solar-powered piece of electro-"art" that tries to capture the desperate emotion that accompanies possibly pointless waiting.

The name is from Samuel Beckett's famous play Waiting for Godot, in which two men wait for the coming of a certain Godot, who might arrive tomorrow, the day after, or never.

So what does the Godot Machine do?

  1. 1. Given some sunshine, a Joule Thief circuit starts charging a bank of capacitors.
  2. 2. Once charged to about 5V, the Arduino Nano is powered.
  3. 3. The Arduino generates a 20-bit true random number, which is shown on a 4-bit LED bar.
  4. 4. This number is compared to another random number, unknown to all, that was stored in eeprom the first time the circuit booted.
  5. 5. If equal, the wait is over, the machine stores this fact in eeprom and from now on the green LED and piezo beeper are activated (if there is enough energy).
  6. 6. If not equal, hope, despair, repeat.

...also, once in a while the generated number is made audible by the beeper, so you don't actually forget that you have a Godot Machine.

Given that the probability to hit the Godot number is 1 over 2^20 or about one in a million, and the machine is not very fast, especially in winter and autumn, it could take years to find it. Your Godot Machine might even become part of your inheritance. While waiting for it to test the next number, you can fantasize about how your distant great great grandchildren may finally see it come to its conclusion. In short: it's the ideal present for the upcoming holiday season!

Step 1: The Schematic

The Godot Machine consists of:

    -A Joule Thief energy harvester (Q1) that charges 9x2200uF capacitors. For those who suffer from helixaphobia (an irrational angst of inductors, while capacitors and resistors pose no such problem), fear not as no manual winding is required: the coupling is created by placing standard coaxial inductors in each other's vicinity as shown here in the 2nd pic. Awesome trick!

    -A discrete transistor power switch (Q2, Q3, Q4), which switches on at 5V1 about and off at around 3.0V. You might want to tune R2-R4 a bit if you use different (general purpose) transistor types.

    -An entropy generator (Q6, Q7, Q8). This circuit amplifies the electronic noise present in the environment from microvolts to volts levels. That signal is then sampled to seed a chaos-based (read on) random number generator. A piece of guitar string acts as an antenna.

    -A LED-bar with 4 LEDs or 4 red separate LEDs, a piezo beeper and a green LED.

    Note that the output of the power switch (collector of Q4) is connected to the 5V pin of the Arduino Nano, NOT to the VIN pin!

    Step 2: Building the Godot Machine

    I built the circuit on a piece of perfboard. Nothing special there. The 2V/200mA solar panel is a leftover from another project. The brand is Velleman. It's easy to pry it open using an sharp knife, to drill holes for screws etc. Circuit board and solar panel are screwed on to two pieces of plywood, as shown in the picture. The idea is that the solar panel can be positioned towards the sun on a window still.

    Step 3: The Code: Random Numbers From Chaos?

    How are the random numbers made? Well, they are Made With Math!

    Instead of using the Arduino random number generator function random(), I decided to write my own Random Number Generator (RNG), just for fun.

    It is based on the logistic map, which is the simplest example of deterministic chaos. Here's how it works:

    Suppose x is some real value between 0 and 1, then calculate: x*r*(1-x), where r=3.9. The result is your next 'x'. Repeat ad infinitum. This will give you a series of numbers between 0 and 1, as in the first picture, where this process is started for the initial value of x=0.1 (red) and also x=0.1001 (blue).

    Now here's the cool part: no matter how close you choose two different initial conditions, if they are not exactly equal, the resulting series of numbers will eventually diverge. This is called 'Sensitive dependence on initial conditions'.

    Mathematically, the map equation x*r*(1-x) is a parabola. As shown in the 2nd figure, you can graphically determine the x-series using what is known as a cobweb construction: start from x on the horizontal axis, find the function value on the y-axis, then reflect against a straight line at 45 degrees angle going through the origin. Repeat. As shown for the red and blue series, even if close initially, they completely diverge after about 30 iterations.

    Now, where does the 'r=3.9' number come from? It turns out that for low values of r, we get only two alternating x-values. Increasing the r-parameter will then at some point switch to an oscillation between 4, 8, 16 values etc. These branchings or bifurcations come more and more rapidly as r is increased, in what is called a 'period doubling route to chaos'. A plot with r on the horizontal axis and many x-iterates overlapped vertically will result in what is known as a bifurcation plot (3rd figure). For r=3.9, the map is fully chaotic.

    So if we calculate many x-updates and sample from them, we get a random number? Well no, at this point it would be a Pseudo Random Number generator (PRNG), since if we always start from the same initial value (after coming out of reset), we would always get the same sequence; aka deterministic chaos. This is where the entropy-generator comes in, which seeds the logistic map with a number created from electric noise found in the environment.


    In words, the random number generator code does this:

    - Measure the voltage from the entropy generator on pin A0. Keep only the 4 least significant bits.

    - Shift these 4 bits into a 'seed' value, repeat 8 times to get a 32-bit floating point seed.

    - Rescale the seed between 0 and 1.

    - Calculate the average of this seed and x, the current state of the logistic map.

    - Advance the logistic map many (64) steps.

    - Extract a single bit from the logistic map state x by checking some insignificant decimal.

    - Shift that bit into the final result.

    - Repeat all steps above 20 times.


    Note: In the code, the Serial.println and Serial.begin are outcommented. Remove the // to check the generated random numbers on the serial monitor.

    To be fair, I haven't statistically checked the quality of the random numbers (e.g. NIST test suite) but they seem to be OK.

    Step 4: Marvel at Your Godot Machine!

    Enjoy your Godot Machine and please share, comment and/or ask if anything unclear.

    While you're waiting for the Godot number to be found, please vote for this Instructable in the Made With Math contest! Thanks!

    Made with Math Contest

    Runner Up in the
    Made with Math Contest