Lesson 2: Letters and Pictures in Bits — ASCII Text and Bitmap Pixels
Time: 50 minutes
Unit: Binary, Pixels, Logic Gates, and Packet Switching | Previous: Lesson 1 | Next: Lesson 3
Goal
Encode and decode text using an 8-bit ASCII lookup table, represent 8 × 8 images as 1-bit and 2-bit bitmaps, and calculate storage unit rates in bits per character and bits per pixel.
Materials
- Lesson 1 binary place-value cards (
128, 64, 32, 16, 8, 4, 2, 1).
- Printed or board-drawn
8 × 8 blank pixel grids (2 grids per student).
- Colored pencils or shading styles (blank, light crosshatch, dark diagonal, solid black) for 2-bit palettes.
Steps
1. Opening (5 min): If Computers Only Store 0 and 1, Where Are the Letters?
Write the byte 01001000 on the board. Ask:
- "In Lesson 1, we decoded 01001000 as the number 64 + 8 = 72. How can a text-messaging app use that exact same byte to display a capital letter instead of the number 72?"
- Introduce the idea of a shared codebook (standard encoding): if every keyboard and screen agrees on which number stands for which letter, then storing numbers is enough to store words.
2. Main Activity Part A (15 min): Decoding and Encoding ASCII Text
Show the class how uppercase English letters are mapped in standard ASCII (American Standard Code for Information Interchange):
| Character |
Base-10 Code |
8-Bit Binary |
Character |
Base-10 Code |
8-Bit Binary |
(space) |
32 |
00100000 |
A |
65 |
01000001 |
! |
33 |
00100001 |
B |
66 |
01000010 |
0 (digit) |
48 |
00110000 |
C |
67 |
01000011 |
1 (digit) |
49 |
00110001 |
... |
... |
... |
? |
63 |
00111111 |
Z |
90 |
01011010 |
Point out two helpful patterns:
1. Capital A is 65 (01000001), so the n-th letter of the alphabet has code 64 + n! Since 64 is the 01000000 bit, the last 5 bits directly tell you the letter's position (1 to 26) in the alphabet.
2. Lowercase a is 97 (01100001), which is 65 + 32 — toggling just the 32-bit switches any letter between uppercase and lowercase!
Worked Example 1: Decoding a 3-Byte Word
Decode 01000011 01000001 01010100:
- Byte 1 (01000011): 64 + 2 + 1 = 67 (3rd letter) → C
- Byte 2 (01000001): 64 + 1 = 65 (1st letter) → A
- Byte 3 (01010100): 64 + 16 + 4 = 84 (20th letter) → T
Word: CAT (3 characters × 8 bits per character = 24 bits).
3. Main Activity Part B (15 min): Bitmap Grids and Bits-per-Pixel Ratios
Now ask: "How do we turn a grid of tiny squares (pixels) into 0s and 1s?"
- 1-Bit Monochrome (1 bit per pixel): Each square uses 1 bit: 0 = white (unshaded), 1 = black (shaded).
- Example 8 × 8 icon (64 pixels total at 1 bit per pixel = 64 bits = 8 bytes of raw uncompressed pixel data, excluding any file headers or metadata):
- Row 1: 00111100
- Row 2: 01000010
- Row 3: 10100101
- Row 4: 10000001
- Row 5: 10100101
- Row 6: 10011001
- Row 7: 01000010
- Row 8: 00111100
(Students shade the 1s on their 8 × 8 grid to reveal a smiling face!)
- 2-Bit Four-Color Palette (2 bits per pixel): What if we want 4 colors (like an early handheld game console: 00 = White, 01 = Light Gray, 10 = Dark Gray, 11 = Black)?
- Each pixel now requires 2 bits, so the unit rate doubles from 1 bit per pixel to 2 bits per pixel.
- For the same 8 × 8 (64-pixel) grid, raw pixel storage doubles from 64 bits (8 bytes) to 128 bits (16 bytes) (excluding any metadata or compression).
4. Discussion & Student Practice (15 min)
Practice Tasks (2.1 – 2.8)
- Task 2.1: Using
A = 65, find the base-10 ASCII code and 8-bit binary byte for uppercase E (the 5th letter) and M (the 13th letter).
- Task 2.2: Decode the 4-byte ASCII message:
01000100 01000001 01010100 01000001.
- Task 2.3: Look at the ASCII table: the character
'1' has code 49 (00110001), while the number 1 in Lesson 1 was 00000001. Why does a computer distinguish between the text character '1' and the number 1?
- Task 2.4 (Unit Rate — Text): A text file contains
150 characters (including spaces) encoded at a unit rate of 8 bits per character. How many total bits and how many bytes does the text file require?
- Task 2.5 (Bitmap Decoding): Draw a
4 × 4 grid and shade the 1s for these four 4-bit rows: Row 1 = 0110, Row 2 = 1111, Row 3 = 0110, Row 4 = 0110. What symbol appears?
- Task 2.6 (Color Depth Ratio): An
8 × 8 sprite uses a 16-color palette where each pixel uses 4 bits (0000 through 1111). What is the unit rate in bits per pixel, and how many raw pixel bits (and bytes, excluding headers/compression) are needed for all 64 pixels?
- Task 2.7 (Aspect Ratio): A game banner measures
120 pixels wide by 80 pixels tall. Write the width-to-height ratio 120 : 80 in simplest whole-number form. If you scale the banner to 300 pixels wide while keeping the exact same aspect ratio, how many pixels tall must it be?
- Task 2.8 (Metadata Reasoning): Suppose you receive a raw stream of
64 bits (0s and 1s) for a 1-bit black-and-white picture, but nobody tells you whether the grid is 8 × 8, 16 × 4, or 32 × 2. Why does the receiver need to know the width and height (whether stored in a file header, sent by a communication protocol, or fixed by a prior external agreement) to display the pixel bits correctly?
Complete Answer Key (Tasks 2.1 – 2.8)
- Answer 2.1:
E is the 5th letter: 64 + 5 = 69 → 01000101. M is the 13th letter: 64 + 13 = 77 (64 + 8 + 4 + 1) → 01001101.
- Answer 2.2:
01000100 = 64 + 4 = 68 (D); 01000001 = 65 (A); 01010100 = 64 + 16 + 4 = 84 (T); 01000001 = 65 (A). Word: DATA.
- Answer 2.3: When
'1' appears inside a sentence or street address (like "12 Oak St"), the screen needs to look up the font glyph for the symbol '1' alongside letters and punctuation; when storing a quantity for arithmetic, storing pure binary (00000001) lets the processor add and subtract directly.
- Answer 2.4:
150 characters × 8 bits/character = 1,200 bits, which is 150 bytes (1 byte per character).
- Answer 2.5: Shading the middle two columns on rows 1, 3, and 4 and all four columns on row 2 forms a cross / plus (
+) or sword/tree icon.
- Answer 2.6: Unit rate =
4 bits per pixel. Total storage = 64 pixels × 4 bits/pixel = 256 bits, which is 256 ÷ 8 = 32 bytes.
- Answer 2.7: Dividing both
120 and 80 by their greatest common factor (40) gives a 3 : 2 width-to-height ratio. Since 300 ÷ 3 = 100, the scaled height must be 2 × 100 = 200 pixels tall.
- Answer 2.8: Without knowing how many pixels belong in each row (the width—supplied via a file header, a protocol message, or a fixed format agreement), the receiver does not know where to wrap to the next line; wrapping every
16 bits instead of every 8 bits scrambles the picture into unrecognizable stripes.
Vocabulary
- ASCII: A standard character-encoding table that assigns numbers (
0 to 127) to English letters, digits, and punctuation marks.
- pixel (picture element): One individual colored square in a grid-based digital image.
- bitmap: An image represented as a row-by-row grid of pixel color codes (whose width and height are supplied by a file header, protocol, or format specification).
- color depth (bits per pixel): The unit rate measuring how many bits are used to represent the color of each single pixel.
Differentiation
- Extra support: Provide a printed alphabet strip listing
A = 65 through Z = 90 with their 5-bit endings (00001 to 11010) so students can focus on matching patterns before doing mental subtraction.
- Extra challenge: Introduce Run-Length Encoding (RLE) compression: in Row 1 of the smiley face (
00111100), instead of listing every bit, write (2 white, 4 black, 2 white). Ask students to test which 8 × 8 drawings shrink with RLE and which pattern (such as an alternating checkerboard 01010101) actually gets larger!
Safety
No physical hazards in this unplugged lesson.
Teacher notes
- Important scope note on Unicode / UTF-8: Make sure students know that 7-bit/8-bit ASCII only had room for English characters. Modern operating systems and web browsers use UTF-8 (Unicode), which stays backwards-compatible with 1-byte ASCII for
0–127 while using 2, 3, or 4 bytes per character to represent over 149,000 characters across global writing systems and emoji.