Teaching the concept of binary logic gates with CodeBug

Library for Educators
6 min readDec 7, 2018
Basic logic gate

In October 2018 we developed and delivered a new learning activity for the first DigiLab pop-up event to held on North Campus using CodeBug’s.

“CodeBug is a little device that you can wear and learn to program. It has 25 LED lights in a 5x5 grid and 2 buttons for you to interact with. It also has 6 ‘legs’ that can be used to connect croc-clips, banana plugs or even sewn to. These legs can be used as inputs or outputs and can even sense an electric current passing through your body.”

CodeBug photo by Gareth Halfacree. Licensed CC BY-SA 2.0

Our aim was to put together an activity which taught the concepts of binary and logic gates. In this post we will look at:

Learning outcomes:

On completion of the activity we wanted learners to be able to:

  • Identify different types of logic gates by testing inputs and the output from each CodeBug.
  • Apply their knowledge, to identify determining unidentified gate types. Explaining their conclusion based on the evidence from their testing.

The learning activity

The concepts of binary numbers and binary or Boolean algebra are fundamental to computing. You can begin to understand how computer components and digital systems function once you know how data is stored as ones and zeros, and how signals with either of these two states can be compared. Logic gates perform operations on one or two inputs that are either high (one) or low (zero) and produce an output signal that depends on the state of these inputs. The most common gates are called AND, OR and NOT, and work much like the query operators available in many search engines.

As a crude example, Boolean operators AND, OR and NOT may help you to search for ‘mercury’ in the field of chemistry excluding results that mention of the Roman god of war.

We programmed a collection of CodeBugs, to act as a different logic gate, using the display to show a one or zero character depending on which input buttons were pressed (high) or unpressed (low).

There are many real world analogies to these gates, which are explained to visitors as they try out each gate in order, learning what they all do, by playing with the appropriately programmed CodeBug for each one. At the end of the line, there is a ‘black box’ mystery gate which the visitor must identify using the knowledge they have gathered so far. Asking them to recall and explain their understanding to reinforce what they have learned.

How we put it together

Each type of logic gate was programmed into a CodeBug using their web-based editor to visually create the code. The block coding like this is like putting together a jigsaw; so it’s much easier to get started, even for complete beginners.

To transfer the code onto a CodeBug, we simply had to plug it into a computer’s USB socket, and drag the code file onto it. This makes it CodeBugs good for learning, playing and prototyping. You can update your program in seconds, and try it out straight away. For those familiar with coding the editor also lets you see what the blocks of code you have built look like as a python or JavaScript program.

We planned out a sequence for people to follow by moving along a line of tables, starting with an introduction sheet, followed by a CodeBug to try out each logic gate, and a description sheet explaining what it does, real life examples, and its significance.

Finally, we had a challenge sheet with the mystery “black box” CodeBug which participants had to try and identify (it was one of the gates they had already seen).

A facilitator was available at all times, and participants were encouraged to ask for help at any time, and to say which gate they thought the final mystery gate was. There were small prizes for anyone attending the DigiLab popup event; originally we planned to link this to the challenge gate. However on reflection we felt this would emphasise knowing the answer & getting it right, over participating in learning about and experiencing the technology so instead anyone who attended was entered into the draw.

What we had to consider

In order to meet the learning outcomes, we had to make sure that each gate was described using simple language and accessible real world examples, this was not always easy.

We planned the sequence of gates to start with simple examples, building up to the gates that are described as combinations of other gates. We left out the most complicated ones on the day.

There were several important points to consider to ensure this session could be delivered smoothly, extending to several pages of A4 when written out entirely. The main points are to test that all the gates are programmed correctly and matched to the right description sheet. Also remembering to have spare batteries available.

What happened on the day

Participants were directed to start at the introductory sheets, then work their way along the line of CodeBug’s. Some students stopped to read all of the introductory information, but some preferred to get hands on with the CodeBugs straight away. For most students, the introductory information could be delivered more quickly by a facilitator, who could check understanding and explain at an appropriate level. However having the sheets there was really useful during busy periods where a facilitator was with another student already.

Most students who tried the CodeBugs were genuinely interested and enjoyed being able to play with something real. The real-world examples given helped students to conceptualise the logic gates.

On the day, we kept the number of gates low, based on available space, and not wanting to overwhelm students with no prior knowledge. Some students had a high level of prior knowledge, and enjoyed talking about the CodeBugs themselves, or were interested in trying out more complex gates. We had a couple of spare CodeBugs on the day so were able to give them an XOR/XNOR/half adder to identify — but these were not on show otherwise. We also had a laptop so we were able to demonstrate the code — this could also be built into the activity in future.

The challenge provided by the Mystery Gates was popular, although there was some frustration during busy periods that the answer wasn’t written down, so they had to ask a facilitator for feedback on their guess.

Tips for delivering this activity

  1. Label each CodeBug with a number corresponding to the sheet it belongs to. This will prevent them from getting mixed up.
  2. Depending on your group/ event attendance you might consider having additional facilitators — e.g. one to welcome and introduce the activity, and one to coordinating the challenge activities .

What improvements can we make?

  1. Develop further real-world examples to help explain each logic gate.
  2. Create further ‘stretch’ activities and discussion points for participants with a prior understanding of the topic.
  3. Provide laptops and further CodeBugs available for those students who wish to try coding themselves.

Download a copy of our materials:

--

--

Library for Educators

Sharing resources for educators, from The University of Manchester Library