Binary Light Switch Encoder

Understanding Binary Code

The term binary describes any system that uses exactly two options, and humans have been using binary-style thinking long before computers existed. A light is on or off. A door is open or closed. An answer is yes or no. For computers, this idea is enough to construct a whole coded language.

With binary code, every piece of data inside a computer, no matter how complex, is built from just two things: ON and OFF. This works because computers are made of billions of tiny electronic switches. Each switch can only ever be in one of two states, ON or OFF, and we can write those two states as 1 for ON and 0 for OFF.

Binary also has its own number system, where each position in a set of eight is worth double the one before it, from 1 to 2, 4, 8, 16, 32, 64, and 128. To find what a binary number is worth, you simply add up the values of every position where the switch is turned ON.

About the Encoder

This tool helps show how computers represent numbers using binary code. Each light bulb stands for one switch inside a computer, and by turning switches on and off in a group of eight we can see exactly how a binary pattern becomes a number.

Each of the eight bulbs represents one bit, with its place value shown above it. Tap any bulb to switch between ON (1) and OFF (0). As you flip switches, the total value of the 8-bit byte will update at the bottom. Tap any of the preset buttons to see how that number is made.

Once you have a feel for how to use the encoder, challenge yourself to complete the activities below!


Binary Light Switch Encoder

Binary Light Switch Encoder

Tap any bulb to turn it on or off. Computers use 1s and 0s — just like these switches!

Try some fun numbers ↓


Activity Challenges

1. Hit the target number!

Your challenge is to make a specific number using the switches, flipping only one switch at a time. Start with the number 42. Rather than just guessing, try to work out before you start which switches need to be ON. Then use the encoder to check your work. Once you've got 42, try 99, then 200, and any random number of your choice after that. What’s the highest number you can create with this single 8-bit byte?

2. Odd or even?

Flip through a few different numbers and look carefully at the lowest switch, the one worth 1. What do you notice? Is there a pattern between whether that switch is on or off and whether your total number is odd or even? Write down your prediction, then test it with at least five different numbers. Can you explain why the pattern works?

3. How high can you count?

Starting from 0, try to count upward in binary by changing as few switches as possible each step. What is the smallest number of switch flips needed to go from 0 to 1? From 1 to 2? From 7 to 8? Keep a tally as you go. What do you notice about which switch flips the most often as you count upward?


Note: Setting Boundaries & Pushing Limits

This widget uses eight bits, or one byte, which can represent any number from 0 to 255. Of course, computers link billions of bytes together to represent numbers far, far beyond this range. Yet no matter how many bits are used, the place-value logic we see here stays the same. So working with the eight bits of a single byte is a great place to start as we get to know binary code. Happy coding!