HackerBox 0126: Imitation Game

by HackerBoxes in Circuits > Electronics

1711 Views, 3 Favorites, 0 Comments

HackerBox 0126: Imitation Game

HB0126 Whole Box.png

Welcome to HackerBox 0126. Explore the profoundly impactful work of Alan Turing, widely considered to be the father of theoretical computer science and an intellectual force behind the pivotal cryptographic victory of World War II. Assemble the TuRING Machine, a ring-structured Turing Machine to experiment with an idealized model of the canonical computing machine using sequential memory to store and retrieve both instructions and data. Contextualize the Turing Machine as an inspiration for all modern computers. Explore the Imitation Game, or Turing Test, as an early philosophical query into Artificial Intelligence. Configure the ESP32-S3 N16R8 CAM Development Board to assemble the ESP Edge Platform for carrying out a number of Edge AI exercises and projects. Raise a hot iron to salute the historical significance of the Heathkit brand.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0126. The full box contents are listed on the product page for HackerBox 0126 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month, you can subscribe at HackerBoxes.com and join the party. Subscription members save at least $15 every month and automatically receive each new HackerBox shipped immediately off the production line.

A soldering iron, solder, and basic assembly tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for tools and supplies along with a wide array of introductory activities and experiments.

The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

WEAR SAFETY GLASSES WHEN SOLDERING, WHEN TRIMMING WIRE LEADS, OR WHEN CUTTING, DRILLING, ETC.

Alan Turing

Turing Coin.png

Alan Turing (1912 – 1954) was an English mathematician, computer scientist, logician, cryptanalyst, philosopher and theoretical biologist. He was highly influential in the development of theoretical computer science, providing a formalization of the concepts of algorithm and computation with the Turing machine. Turing is widely considered to be the father of theoretical computer science. He graduated from King's College, Cambridge, and in 1938, earned a doctorate degree from Princeton University.

During World War II, Turing worked for the Government Code and Cypher School at Bletchley Park, Britain's codebreaking centre that produced Ultra intelligence. He led Hut 8, the section responsible for German naval cryptanalysis. Turing devised techniques for speeding the breaking of German ciphers, including improvements to the pre-war Polish bomba method, an electromechanical machine that could find settings for the Enigma machine. He played a crucial role in cracking intercepted messages that enabled the Allies to defeat the Axis powers. After the war, Turing worked at the National Physical Laboratory, where he designed the Automatic Computing Engine, one of the first designs for a stored-program computer. (Wikipedia)

The Alan Turing Coin artwork was adapted from Matthew Leadbeater's Line Art Portraits of Logicians commissioned as part of the Open Logic Project. The project is a collection of teaching materials on mathematical logic aimed at a non-mathematical audience, intended for use in advanced logic courses as taught in many philosophy departments.

Turing Machines

How Turing Machines Work

A Turing machine is an idealized model of a central processing unit (CPU) that controls all data manipulation done by a computer, with the canonical machine using sequential memory to store data. Typically, the sequential memory is represented as a tape of infinite length on which the machine can perform read and write operations. (Wikipedia)

The TuRING Machine presented below is a functioning show-and-tell Turing Machine that implements its sequential memory "tape" as a ring of 24 LEDs.

ATmega328P Nano

6 Arduino Nano.png

To build the TuRING Machine Kit, we'll be leveraging a classic ATMEGA328P 16 MHz Arduino Nano microcontroller development board.

Before soldering anything...

Power up the Arduino Nano and verify the tool chain.

When power is first applied to the Arduino Nano using a USB-C cable, the Power LED (labeled PWR on the silkscreen) will illuminate and the Onboard LED (labeled L on the silkscreen) will slowly blink.

If necessary, install the Arduino IDE.

Run the Arduino IDE.

In the IDE, select Tools > Board > Arduino AVR Boards > Arduino Nano

Also select Tools > Port > (the USB port connected to the Nano)

Open the example sketch:

File > Examples > Basics > Blink

This is the "LED slow blink" code that came on the board from the factory.

In the sketch, change both delay calls from 1000 to 100 (milliseconds).

This will flash the LED ten times faster (with ten times less delay).

Compile and upload the modified sketch.

When the upload completes successfully, the LED should be blinking faster than before.

Consider changing the delay values to alter the pattern and timing of the LED blink in a couple of different predictable fashion.

The TuRING Machine

TuRING Assemble.png

The HackerBox TuRING Kit is inspired by Mark Wilson's Turing-ring project and runs the same code with just one simple modification. Mark's project was in turn inspired by the Turing Machine Model 1 from Zafar Iqbal.

Assemble the TuRING Hardware

Position the 24 Pixel WS2812B RGB LED Ring onto the front of the TuRING PCB as shown. Carefully center the LED ring within the corresponding annulus on the PCB and align the IN, 5V, and GND pins as shown.

Affix the LED ring onto PCB with double-sided tape, cyanoacrylate, hot glue, or some other adhesive.

Form one wire from the Axial Lead Resistor into a zigzag shape to fix against a corresponding pair of LED ring pads, solder it onto both pads, and snip the wire lead to length.

Repeat the previous step three times to connect the IN, 5V, and GND lines as shown.

Discard the Axial Lead Resistor itself since we were only using to for its nice, solid, yet thin, lead wires.

Solder the Arduino Nano onto the back side of the PCB with the USB port adjacent to the PCB edge as shown.

Power the Arduino Nano to be sure that it still boots up and runs the blink sketch programming onto it earlier.

Remove the power after the verification test.

Solder the Tiny RTC DS1307 I2C Clock Module onto the back side of the PCB with the battery holder facing outward as shown. Note that the clock module packaging does not include header pins. However, there is a strip of approximately 20 header pins in the small parts baggie. The necessary 5 pin and 7 pin headers can be easily snipped from this longer header strip.

For the Tiny RTC DS1307 I2C Clock Module to maintain time, a CR2032 Coin Cell can be inserted with the "+" side facing outward. The optional CR2032 Coin Cell is not included.

Solder the EC11 Rotary Encoder as shown and press its silver knob into place.

The Metallic Alan Turing Coin Sticker may be affixed to the center area of the TuRING Machine if you take care to trim away (or insulate) the region around the five pin header of the RTC module. The foil material of the sticker is conductive and may short the header pins. Alternatively, slap "sticker Alan" on a laptop for some instant geek cred!

The TuRING Machine Arduino Sketch

Open the Arduino IDE.

Use the IDE's Library Manager to search for, and install, the Adafruit NeoPixel Library.

Use the IDE's Library Manager to search for, and install, the RotaryEncoder Library by Matthias Hertel.

Browse to Mark Wilson's github repo and grab all the files.

Open the sketch TuringRing.ino in the Arduino IDE.

Notice the many file tabs across the top of the code window of the IDE.

Click to the tab for the PixelRing.h file.

Scroll down to around line 94.

TopPhysicalPixelN = 15; // the one at 12 O'Clock

Change the value from 15 to 0 (zero).

Click to the tab for the Wheel.cpp file.

Scroll to Line 9.

RotaryEncoder encoder(PIN_ENCODER_A, PIN_ENCODER_B, RotaryEncoder::LatchMode::TWO03);

Change the LatchMode value from TWO03 to FOUR3.

Compile and Upload the Sketch.

After Programming...

The TuRING Machine starts up by illuminating all of the LEDs red, then green, then blue.

Next the LEDs display a rainbow pattern that cycles around the ring.

The LEDs finally turn off with only the A position flashing white.

Click the encoder's center button straight down to ender EDITOR mode.

Rotate around to the MENU position and click the button again.

Rotate to A (Example) position and click again.

Rotate to C (Binary Counter) and click again.

Click again to re-enter EDITOR mode.

Rotate to RUN and click again.

Observe the LEDs as they display a binary count.

Turn the knob to increase, or decrease, the execution speed.

But wait. There's more...

Explore the full capabilities of the TuRING Machine with the readme.txt file in the code repo.

The Imitation Game

The Turing test: Can a computer pass for a human? - Alex Gendler

The Imitation Game, or Turing Test, seeks to determine a machine's ability to exhibit intelligent behavior equivalent to that of a human. In the test, a human evaluator judges a text transcript of a natural-language conversation between a human and a machine. The evaluator tries to identify the machine, and the machine passes if the evaluator cannot reliably tell them apart. The results would not depend on the machine's ability to answer questions correctly, only on how closely its answers resembled those of a human.

The test was introduced by Turing in his 1950 paper "Computing Machinery and Intelligence" opening with the words: "I propose to consider the question, 'Can machines think?'." Since Turing introduced his test, it has been highly influential in the philosophy of artificial intelligence, resulting in substantial discussion and controversy, as well as criticism from philosophers like John Searle, who argue against the test's ability to detect consciousness.

A 2014 movie about Alan Turing titled The Imitation Game (trailer) is definitely worth seeing.

ELIZA 1966

In 1966, Joseph Weizenbaum at MIT created ELIZA to simulate a psychologist responding to text input. ELIZA inspired many users and observers to ascribe human intelligence to the computer. ELIZA was one of the first chatbots and one of the first programs capable of attempting the Turing Test. (Wikipedia)

Try ELIZA in a web browser.

Watch this video of ELIZA (running on an Apple 1) conversing with ChatGPT 3.5.

Run ELIZA on a microcontroller using uLisp.

ESP32-S3 N16R8 CAM Development Board

ESP32.png

The ESP32-S3 N16R8 CAM Development Board features an ESP32-S3 WROOM N16R8 SoC module that integrates complete Wi-Fi and Bluetooth Low Energy functionality. The ESP32-S3 has support for vector instructions in the MCU, which provides acceleration for neural network computing and signal processing workloads. The N16R8 variant of the WROOM module incorporates 16 MB of Flash and 8 MB of PSRAM.

As shown in the illustration above, the development board also includes:

  1. Four LEDs (PWR, TX, RX, and IO2)
  2. One WS2812 RGB LED (IO48)
  3. One DVP24 Camera Port (14 I/O as shown in the image above)
  4. One MicroSD Card Slot (IO38, IO39, IO40 as shown in the image)

The ESP32-S3 Development Board also features two USB-C ports. The USB-UART port is nearest the GND pin and interfaces through the CH343P USB to UART chip on the rear of the board. The USB-OTG port is nearest to the 5V pin and interfaces directly to the ESP32 SoC.

Before soldering anything...

Power up the ESP32-S3 Development Board and verify the tool chain.

Apply USB power to the USB-UART port.

The Green PWR "ON" LED with illuminate and the RGB LED will cycle red, green, blue, repeat.

Within the Arduino IDE, use the Boards Manager to search for ESP32 (by Espressif Systems).

Select that board package and hit install.

Select:

  1. Tools > Board > esp32 > ESP32S3 Dev Module
  2. Tools > Port > (the USB port connected to the ESP32S3 Dev Module)
  3. Tools > Flash Size: 16MB
  4. Tools > PSRAM > OPI PSRAM

Open the example sketch:

File > Examples > Basics > Blink

Compile and upload the sketch.

The RGB LED should blink white.

Change the three entries in the sketch for LED_BUILTIN to 2.

Compile and upload the sketch.

The blue IO2 LED should now blink instead.

SoC Programming Mode...

If, at any time, the ESP32 refuses to accept uploading a sketch, hold down the BOOT button on the board, press and release the RST button, and then release the BOOT button. This procedure forces the SoC into programming mode. It may be required on the first programming attempt and then never again, or it may be required more often. Just remember this procedure for any time it is needed. It can be applied to pretty much any ESP32 target board.

Assemble the ESP Edge Kit

ESP Edge ASM.png

The ESP Edge platform can support a wide variety of Edge AI applications.

In addition to the microSD slot and the DVP24 camera interface built into the ESP32-S3 development board, the ESP Edge PCB adds an OLED display, an INMP441 digital microphone, a MAX98357A audio output module, a small speaker, and two tactile momentary switches.

The ESP Edge Kit is quite straight forward to assemble. Two twenty pin female header sockets are provided to allow the ESP32-S3 development board to be plugged in and out.

As shown by the red ovals in the image, ONE PIN SHOULD BE REMOVED prior to soldering the female headers to the PCB. That is the 8th pin from the bottom on the right side as shown in the image. The pin should be pulled entirely out from the pin side of the socket. This pin corresponds to the IO0 (zero) pin of the ESP32-S3 development board.

The other components and modules for the ESP Edge Kit are assembled just as shown in the image. There should be nothing unexpected or unusual when closely following the image. For example, notice the orientation of the microphone module. The "sound input" is the tiny hole through the module's PCB (just above the microphone icon). The sound does not go into the metal can on the reverse side. Accordingly, the metal can and other components are mounted facing down against the PCB and the tiny hole is facing outward, as shown in the image.

Once assembled, the following connections are created between the ESP32 and the various peripherals. These I/O pin associations can be plugged into a variety of ESP32 projects...

IO01 OLED_SCK
IO02 OLED_SDA
IO03 SW_BOT
IO45 SW_TOP // with jumper **
IO14 MIC_SD
IO41 MIC_WS
IO47 MIC_SCK
IO48 AMP_BCLK
IO21 AMP_LRC
IO42 AMP_DIN

Optional Top Momentary Switch (SW_TOP) Jumper Wire **

To connect the top button switch to IO45, place a jumper wire of about 5cm on the back side of the PCB between the two pins marked by green ovals in the image above. This jumper is optional and can be added later should you ever desire to use both of the momentary switch buttons.

ESP Edge Projects

ESP32 AI assistant - version 2: Real Voice Input with INMP441! (16MB Memory Upgrade)

Grab the attached ESP_Edge_Echo.ino sketch for a quick demonstration of configuring and exercising each of the peripherals on the ESP Edge platform.

Use the IDE Library Manager to search for, and install, the Adafruit_SSD1306 library along with dependancies.

Example projects that could be targeted to the ESP Edge:

  1. Code repository for the video shown above.
  2. ESP32 Realtime AI Voice Assistant with OpenAI and Langchain
  3. Object Detection using Edge Impulse
  4. ESP32 Gemini-Powered Voice Assistant
  5. ESP-Claw

Downloads

A Question Worth Asking

The Mistake That Built Heathkit, and the America That Buried It

"The question worth asking is whether anything like it can be built again who stands to benefit if it never is?"

We hope you are enjoying this month's HackerBox adventures into electronics, computer technology, and hacker culture. We aim to curate a challenging and rewarding experience of learning through experimentation and exploration. Thank you for joining us on this journey.

Reach out and share your success in the comments below. Email support@hackerboxes.com anytime with questions or whenever you need some help.

Hungry for more? Surf over to HackerBoxes.com and join us as a monthly HackerBox subscription member. You'll get a cool box of hackable gear delivered right to your mailbox every month and you'll enjoy a generous member discount.

Please consider sharing this free Instructable with others who may be interested in learning about these subjects. Word of mouth advertising is the greatest compliment that we can receive. We sincerely appreciate your support.