Automated Logic Circuit Tester


I have been teaching Digital Systems 1 for a number of semesters during my career as a lecturer. Digital Systems 1 is all about number systems, basic logic gates and combinations of these gates which can create modules like adders, subtracters, multiplexers, flip-flops, decoders, etc.

The one thing taking up the most time when grading student designs, is testing the logic circuits they build on their breadboards. But now... It's a lot quicker.


Each one of the circuits are build from a design which starts with a truth table with up to 4 inputs, giving 16 different input combinations. Most of these circuits also have more than output. The circuit is tested by applying an input condition and comparing the received output value with the value from the designed truth table. This is repeated until all the input conditions have been tested.

Up until recently I graded truth table outputs by physically setting different input values, using dip switches, and then comparing the received output value with the output value on the truth table. This takes A LOT OF TIME!!

I don't know why this took me such a long time, but recently, while contemplating how I'm going to grade all the boards in the little time I have, it hit me: Why not build something that can do it automatically!


It took me about 20 minutes to write a program using an Arduino Uno which does the following

Automated Tester

  1. Read data from an array set up to resemble the truth table and send those bits to the output pins on the Arduino Uno
  2. Read a digital bit or bits back, depending on the number of outputs on the logic circuit
  3. Compare the read bit/s with an array according to the output column/s of the truth table
  4. Increase the grade if the read data is correct
  5. Repeat until all the input combinations from the truth table have been tested

On this photo you can see the the student's breadboard above the breadboard with the Arduino Uno on it. The green wires are the wires carrying the data from the input columns in the truth table (4 x input pins) and the yellow wires are the connected to the output side of the logic circuit carrying the data bits back to the Uno for testing (4 x output pins).

The Uno is connected to a PC, using the USB port, giving feedback of the circuit-under-test and this is then used to grade the students' circuit. This feedback also allows me to find mistakes quicker, thereby giving valuable feedback to the students and allowing them to correct mistakes in less time.

Step 1

//Truth table outputs for column A, B, C and D
boolean outA[] = {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}; \\LSB output
boolean outB[] = {0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1};
boolean outC[] = {0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1};
boolean outD[] = {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1}; \\MSB output

This is the truth table data and you'll notice this is just a normal truth table turned on it's side, with outA being the LSB (least significant bit) and outD the MSB (most significant bit).

for (int cnt=0; cnt < maxElements; cnt++)

//Writes the truth table to the outputs
digitalWrite(pinA, outA[cnt]);
digitalWrite(pinB, outB[cnt]);
digitalWrite(pinC, outC[cnt]);
digitalWrite(pinD, outD[cnt]);

In lines 14 to 17 the data from the truth table arrays (outA, outB, outC and outD) are sent to the output pins. The variable cnt is used to count through all the different input combinations. In this case it will count form 0 through 15.

Step 2

//Reads the data from the digital circuit

The digital values on the input pins are read and stored. These values are the output values from the logic circuit.

Step 3 and 4

//The output from the digital circuit is test against the MEMO array for
//    correctness of the digital circuit
//Change the values in the MEMO arrays to test different output columns
char memo1[] = {'1','0','X','X','1','0','0','X','1','0','X','X','0','X','X','X'};
char memo2[] = {'1','1','X','X','1','1','0','X','1','0','X','X','1','X','X','X'};
char memo3[] = {'1','0','X','X','1','0','1','X','1','0','X','X','1','X','X','X'};
char memo4[] = {'1','1','X','X','1','0','1','X','1','1','X','X','1','X','X','X'};

This section of code is the 'memo' against which the input values will be compared. I have also include don't-care conditions (X).

if (memo1[cnt] != 'X')
char inChar = '0';
if (inVal) inChar = '1';
if (inChar == memo1[cnt]) grade++;
} else

This section of code is inside the cnt loop and repeated for every input pin that must be tested. On every iteration of the cnt loop, the input value is compared against the next value in the memo array.

The memo value is compared against the input value and if it is the same, the grade is increased. If the memo value is 'X', nothing is compared since it is a don't-care value.

Step 5

The above steps are repeated until all the input conditions have been sent to the logic circuit and all the outputs have bean read. While this loop is in progress, data is continually sent, through the USB cable, to the PC screen indicating the state of the inputs and outputs and also the grade received.Automated Tester Output


This is the best part! It no longer takes me about 5 to 10 minutes per circuit (depending on the amount of outputs) to test and grade.

Previously, in order to fit all the students into the allotted time slot, they were divided into groups (in order to minimise the amount of circuits to test) and random inputs were tested to determine if the circuit works.

Most of the time used to test the circuit is used to connect the IO pins from the Uno to the breadboard. Once this is done, with the push of a button, I get a result showing me if the circuit works and if it does not work, which of the input combinations are not working allowing me to give valuable feedback to the students.


At this stage there are two things that need to change:

  • The unit must be completely portable and not dependant on a PC
  • Something must be done to decrease the time it takes to make all the connections to the circuit-under-test

I have already started to port the code to an Arduino Mega with a TFT screen for total portablility and have plans to create a custom shield in order to speed up the process of connecting all the wires.


One comment

  • Lehlogonolo Sekgonyane

    Thanks for all the source code and the tutorials published on these website, I'm still looking at your work and applying some of the features on my personal projects.

Leave a Reply

Your email address will not be published. Required fields are marked *