Building a Binary LED Simulation with ESP32

Turning an Abstract Computer Science Concept into Something Students Can Touch

This Picture Edited by ChatGPT

One of the challenges I often encounter when teaching Computer Science to Grade 7 students is explaining concepts that they cannot physically see.

Analog and digital data is a good example.

Students can easily understand that a light can be ON or OFF, but the idea that computers need to convert information from the physical world into digital data can feel quite abstract.

So, rather than explaining it only through slides and diagrams, I decided to build a small physical simulation using an ESP32, LEDs, push buttons, and a potentiometer.

The goal was simple:

Can I make my students see the difference between analog and digital data?

The Idea Behind the Project

For this project, I wanted to create two different types of input.

The first is a push button.

A push button represents a simple digital input because we can treat its state as two possibilities:

Pressed → 1

Not pressed → 0

The second input is a potentiometer.

Unlike the push button, the potentiometer does not simply have two states. As I turn the knob, its output changes gradually across a range of values.

This makes it useful for demonstrating an analog signal.

Students can physically turn the knob and observe that the input is not simply "ON" or "OFF."

That difference is exactly what I want them to understand.

From Analog to Digital

The potentiometer is particularly interesting because it allows students to experience what happens when an analog signal is read by a digital system.

The physical world is full of continuously changing quantities.

  • Temperature
  • Sound
  • Light intensity
  • Pressure
  • Volume
  • Position

These are examples of information that can vary continuously.

The ESP32, however, is a digital device. When it reads an analog input, the signal is converted into a numerical value that the microcontroller can process.

So I can demonstrate a simple chain:

Physical world → Analog signal → ESP32 → Digital value → LED output

This gives students a much more concrete picture of what happens inside digital systems.

Using LEDs to Represent Digital Information

I also added several LEDs to the circuit.

The LEDs provide a visual representation of the values being processed by the ESP32.

For example, the system can represent different values using combinations of LEDs:

0000

0001

0010

0011

0100

and so on.

This introduces another important concept in the IGCSE Computer Science curriculum:

binary representation.

Students can see that computers do not need to represent information using the same form humans use. A number can be represented using combinations of binary digits, and those binary states can even be represented physically by LEDs.

Why I Built It for Grade 7

When teaching younger students, I don't want their first experience with a concept to be:

"Here is the definition. Memorise it."

Instead, I want them to ask:

"What happens if I turn this?"

"Why did that LED change?"

"Why does the button only have two states?"

"How does the computer know what value the sensor is giving it?"

Those questions create much better opportunities for learning.

The hardware becomes a starting point for discussion.

Students can interact with the circuit, make predictions, observe the output, and then connect their observations to the Computer Science concepts they are learning.

Analog vs Digital: A Physical Demonstration

The setup allows me to demonstrate the difference quite naturally.

Digital Input

The push button can be treated as:

0 → OFF

1 → ON

There are two discrete states.

Analog Input

The potentiometer provides a changing value.

Instead of simply asking:

    "Is it ON or OFF?"

we can ask:

    "What is the current value?"

As I rotate the potentiometer, the value changes continuously within the available input range.

The ESP32 then reads that signal and processes it digitally.

This gives students a simple physical example of why computers need ways to sample and represent real-world information digitally.

Learning by Building

There is also another reason I enjoy creating projects like this.

As a Computer Science teacher, I don't want technology to become something students only consume.

I want them to understand how it works.

An ESP32 is small, inexpensive, and relatively accessible, but it opens the door to many Computer Science concepts:

  • Binary numbers
  • Digital signals
  • Analog signals
  • Sensors
  • Input and output
  • Data representation
  • Microcontrollers
  • Programming
  • Physical computing
  • Automation

A single breadboard can therefore become a small laboratory for Computer Science.

What's Next?

This project is still a prototype, and I can already see several ways to turn it into a proper classroom learning activity.

For example, I could create a challenge where students are given a decimal number and have to determine which LEDs should be ON.

Another activity could ask students to rotate the potentiometer and observe how the analog value changes.

Eventually, I would also like to connect the ESP32 to a simple web interface so students can see the analog input value, converted digital value, and binary representation at the same time.

That would allow the physical circuit and the digital interface to work together.

Another joyful yet meaningful idea is to use a printed activity worksheet from Twinkl.

From a Breadboard to a Learning Experience

For me, this project is less about building an impressive electronic device and more about finding a better way to teach an abstract concept.

When students can physically press a button, turn a potentiometer, watch an LED change, and then connect that observation to analog data, digital data, and binary representation, the concept becomes much more tangible.

That's what I love about teaching Computer Science.

Sometimes, the best way to explain what happens inside a computer is to first build something outside of it.

And this little ESP32 project is my attempt to do exactly that.

Thank you for visiting my blog, I appreciate it! ✋😀

Comments