Tell The Truth

Curriculum Links

The Tell the Truth! game can be used as a fun way to introduce logic gates &Truth Tables to students at KS4. The OCR GCSE Computer Science specification requires students to have an understanding of these topics (OCR J276 specification section 2.4 – computational Logic.

In addition the game code, consisting of several hundred lines of Python Code, can also be used as a teaching aid.

It has to be said that building this project requires a considerable amount of time that many teachers just don’t have. For this reason we have built a complete game set that is available to schools and colleges at no cost.Contact us for further details.

About the Game

Tell the Truth! is a game that runs on a Raspberry Pi or other hardware. It simulates logic gates by randomly lighting up a grid of lamps in a specific pattern that represents the Truth Table of a particular gate e.g. AND, OR etc. The player has a short amount of time to recognise the pattern of lights and select the appropriate input. For example, in the truth table below the game has randomly generated an OR gate.


To make the game more interesting, rather than pressing buttons or keys to make the selection we use fresh fruit connected to a Makey Makey board; the board acts as a keyboard emulator and feeds player responses to the Raspberry Pi.Truth Game process diagram

Where possible the name of the fruit should sound similar to the gate. So, use an ORange for the OR gate. (See what we did there!)

Game Levels

The game can be played at three different levels:

  • Level 1 – The only combinations outputted are AND, OR, NAND, & NOR.
  • Level 2 – Adds XOR & XNOR
  • Level 3 – At level 2 there are six output combinations that represent a valid logic gate. Actually there are 24=16 possible combinations, i.e. there are 10 outputs that do not represent a gate – these are added at Level Three. Use one fruit to represent these ‘Gibberish’ outputs – we used a Grapefruit for Gibberish! (or you could use Rhubarb for Rubbish)
0 0 0 0 1 1 0 1 0 0 0 0 0 1 1 1 1 1
1 0 0 1 1 0 1 0 0 0 0 1 1 0 0 1 1 1
0 1 0 1 1 0 1 0 0 1 1 0 0 1 1 0 0 1
1 1 1 1 0 0 0 1 0 0 1 0 1 0 1 0 1 1

The Code

Tell the Truth! is written in Python and includes 872 lines of code. The code is shown below.

Code Notes

  • The game uses music to signal if a correct response has been given.
  • The game flashes the output lights randomly for a few seconds before presenting an output.
  • In the Truth Table above columns A & B are inputs and so do not change. However, the gPiO box that drives the lights has six output channels, so to make the game more visually interesting we also flash columns A & B before returning them to the values in the table.