In Stephen Welch's book, The Welch Labs Illustrated Guide to AI, Chapter 1 challenges the reader to "Build Your Own Perceptron", using switches and potentiometers. A perceptron has N binary inputs, and N+1 weights (the extra weight is a bias, as though there were one more input that is always +1). It computes the sum-of-products of the weights and inputs, and compares that to a reference voltage.
Here's my version. It fits on one breadboard. I only implemented 2 inputs, but could probably have fit 8.
The switches are the key - DPDT, locking. I have them configured so the output of each switch has the battery voltage in one polarity or the other. Unfortunately, the switches I found on Amazon are not wide enough to span the breadboard gap! They are square, 3 pins on a side, but need to be one pin width wider to span the gap properly. I found that I could bend the pins a bit to get them to fit 2 switches into a 14 pin socket, which itself spans the gap. If I had switches that fit the breadboard properly, I would have wired up more inputs.
A 10K potentiometer is wired across the outputs of each switch. It acts as a weight between -1 and +1. Those voltages from the potentiometers are averaged by connecting them with equal size, large resistors. The average voltage connects to a 10324A OpAmp chip, compared to a reference voltage; the OpAmp drives LEDs - one for above threshhold, one for below threshhold. You could do it with just one op amp, but then the LEDs don’t get comparable brightness. I liked the symmetry this way, and the package has multiple op amps in it anyway.
Materials:
100 Ohm Resistor 1
LED 2
10324A Op-Amp 1
Locking DPDT switches N
DIP Sockets N/2
10K potentiometer N + 1
100K resistor N + 3
Battery
Breadboard
breadboard wires
The 10324A OpAmp chip has 4 OpAmps in it. That means we can power two perceptrons. Leaving the first one as is, I hooked up a second one to have 3 inputs - the same 2 inputs as the first, plus the output of the first perceptron.
With two layers, it is possible to tune carefully to implement an XOR.
I changed how the LEDs were connected to the perceptron outputs, and increased the resistors there. That makes the LEDs less bright, but is necessary so the first perceptron output can drive the second.