Microbit Computer Science
Beginner
80 mins
Teacher/Student led
What you need:
Chromebook/Laptop/PC

Data Representation

Explore how computers represent data using binary code. In this lesson, you'll learn the basics of converting text, images, and sound into 0s and 1s, with hands-on tasks to help you understand the process.
Learning Goals Learning Outcomes Teacher Notes

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Introduction

    In today's digital world, everything from the text you read to the images you see and the sounds you hear is processed by computers using binary code – that's just 0s and 1s. This lesson will help you understand how that works, and you'll get hands-on with some practical tasks to see it in action. By the end, you'll have a clear idea of how computers turn real-world data into digital form and why binary is so important.

    Here's what we'll cover:

    1. Binary Representation of Text: Learn how systems like ASCII convert letters and symbols into binary, and try converting your own name.
    2. Binary Representation of Images: Explore how images are made up of pixels represented in binary, and code your own simple images in a simulator.
    3. Binary Representation of Sound: Discover how sound waves are digitised through sampling, including concepts like sampling rate and bit depth, and experiment with creating custom sounds.
    4. Practical Tasks and Wrap-Up: Put it all together with activities like making ASCII art, and review the key principles of data representation.

    2 - Binary Representation of Text

    Text in computers is represented using binary codes, which are made up of only 0s and 1s. A common system for this is ASCII, short for American Standard Code for Information Interchange. Each character, like a letter or symbol, is given a unique number in decimal (base 10), and that number is then converted to binary (base 2). For example, the letter 'A' has an ASCII value of 65, which in binary is 01000001. This binary code allows computers to store and process text efficiently.

    Below is a table showing the uppercase English letters, their ASCII decimal values, and their binary representations. Take a moment to look at the patterns – notice how each letter's binary code changes slightly as the decimal value increases.

    CharacterASCII DecimalBinary
    A6501000001
    B6601000010
    C6701000011
    D6801000100
    E6901000101
    F7001000110
    G7101000111
    H7201001000
    I7301001001
    J7401001010
    K7501001011
    L7601001100
    M7701001101
    N7801001110
    O7901001111
    P8001010000
    Q8101010001
    R8201010010
    S8301010011
    T8401010100
    U8501010101
    V8601010110
    W8701010111
    X8801011000
    Y8901011001
    Z9001011010

    3 - Practical Task: Convert your Name

    To help you understand how text is stored and processed in computers, we are going to convert your name from letters to ASCII codes and then to binary.

    Follow these steps to complete the task:

    1. Choose your first name or a short word that you want to convert. For simplicity, use only uppercase letters, as the ASCII table from the previous step focuses on them.
    2. Refer back to the ASCII table provided in the 'Binary Representation of Text' step. For each letter in your name, find the corresponding decimal value (e.g., 'A' is 65).
    3. Write down the decimal values for each letter in sequence. For example, if your name is 'ALICE', the decimal values would be 65, 76, 73, 67, 69.
    4. Next, convert each decimal value to its binary representation. You can use the binary column in the table, or convert it yourself by repeatedly dividing the decimal number by 2 and recording the remainders, reading them from bottom to top to get the binary digits. Remember to use 8 bits for each binary number, adding leading zeros if necessary. 
    5. Finally, write out the full binary string for your name. This is a format that a computer can understand because computers only understand binary data, consisting of 0s and 1s.

    For example, to convert 65 (the letter A) to binary:

    1. divide 65 by 2 to get 32 with a remainder of 1
    2. divide 32 by 2 to get 16 with a remainder of 0
    3. divide 16 by 2 to get 8 with a remainder of 0
    4. divide 8 by 2 to get 4 with a remainder of 0
    5. divide 4 by 2 to get 2 with a remainder of 0
    6. divide 2 by 2 to get 1 with a remainder of 0
    7. divide 1 by 2 to get 0 with a remainder of 1
    Reading the remainders from bottom to top gives 1000001, so add a leading zero to make it 01000001 (8 bits). For 'ALICE', this would give you 01000001, 01001100, 01001001, 01000011, 01000101.

    4 - Practical Task: Make Some ASCII Art

    Now let's create some ASCII art using an online tool. ASCII art uses text characters to form images, and each character has a binary code.

    Follow these steps to complete the activity:

    1. Go to the ASCII art drawing tool by clicking here. This tool allows you to draw and generate ASCII art easily.
    2. Once on the site, use the drawing tools to create a simple image or design. For example, you could make a smiley face, a heart, or a basic shape. Experiment with different characters to see how they form the image.
    3. After creating your art, copy the ASCII code that represents your drawing (Edit > Select All and then Edit > Copy). This is a string of characters that make up the image.
    4. Paste the text into a notepad or document and you'll see your picture made up of ASCII characters.


    5 - Binary Representation of Images

    Images on computers are not stored as continuous pictures but as digital data composed of small squares called pixels. Each pixel acts like a tiny dot that contributes to the overall image, and its colour or brightness is represented using binary code – sequences of 0s and 1s. This is because computers can only process binary data, making it essential for efficient storage and manipulation.

    For simple black-and-white images, each pixel can be represented with just one bit: for example, 1 might mean the pixel is 'on' or black, and 0 means 'off' or white. This keeps things straightforward and uses less space. However, for more detailed images with shades of grey or full colour, more bits are needed per pixel. For instance, using 8 bits per pixel allows for 256 different levels of grey or colours, enabling richer and more realistic images.

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of DigitalSkills.org. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more