Table of Contents
1 Overview
By the end of section 3, students have constructed the Ledger Art Project.
In lesson Lesson 4-1 (Binary), students learn binary and develop a communication
protocol that maps the letters of the alphabet to decimal and then binary. In
lesson Lesson 4-2 (Encryption), students use their binary communication
protocol to create an encryption technique and add an encrypted message on their
Ledger Art Project.
The Encryption Project is from Lesson 4-2 (Encryption), and uses five of the
NeoPixels on the Circuit Playground Express to represent a 5-bit binary number.
This guide will build on the Ledger Art Project described in the
Ledger Art Project Guide, and will be written in the first
person to make visible the design and computational decisions made in this
individual project.
2 Plan
In order to create a 5-bit encryption for my message, I first needed to map the
letters of the alphabet to decimal numbers. I filled out the
5-Bit Communication Protocol
from Lesson 4-1 (Binary). In my protocol,
I decided to make A = 1, B = 2, C = 3, … , Z = 26.
I then needed a message to send. Since my Ledger Art Project is built around the
idea of being in nature, I chose nature as the message I wanted to send using
the NeoPixels on the Circuit Playground Express.
Using the NeoPixel guide in Lesson 4-1 (Binary),
I then storyboarded the code
using the student handout from Lesson 4-2 (Encryption) to make my message:
Letter |
Decimal |
Binary |
NeoPixel Pin State |
N |
14 |
01110 |
0 OFF 1 ON 2 ON 3 ON 4 OFF |
A |
1 |
00001 |
0 OFF 1 OFF 2 OFF 3 OFF 4 ON |
T |
20 |
10100 |
0 ON 1 OFF 2 ON 3 OFF 4 OFF |
U |
21 |
10101 |
0 ON 1 OFF 2 ON 3 OFF 4 ON |
R |
18 |
10010 |
0 ON 1 OFF 2 OFF 3 ON 4 OFF |
E |
5 |
00101 |
0 OFF 1 OFF 2 ON 3 OFF 4 ON |
I was now ready to begin coding my project.
3 Program
Since NeoPixels have data stored for their brightness and color, I first created
an on start block to initialize the colors I will use in variables and set the
brightness to 255 (full brightness). I created a variable called on to represent
a NeoPixel (bit) being on and a variable called off to represent a NeoPixel (bit)
being off. One question might be why we need to create a color for off. No matter what,
we will need to manually turn the LED off (which is Black). To make my project more interesting,
I used a different color than Black for my off. Students can choose whatever they want.
I decided to make the color cyan on and the color magenta off. Cyan is
Red 0 Green 255 Blue 255 and Magenta is Red 255 Green 0 Blue 255. So I used the
RGB block in the LIGHTS menu of MakeCode to create those two colors. I could have also
used the preloaded colors in MakeCode, but I wanted something different for mine.
Having my variables set up, I decided to turn each letter into its own function.
In this way, I could iteratively and sequentially test each letter on my Circuit
Playground Express.
Having tested my code, I realized that it would be very difficult to know when the
message starts and ends. So I created a function that has all five NeoPixels flash
white at the end of the message.
At this point, I was ready to put it all together. I made a forever block and
called each of the letter functions with a one second pause between them. I ended
the message with the End Message function.
In order to clean up my code a little, I created a new function called Encryption Message
and put all the code in there. Then my forever loop only had one line of code in it.
I downloaded the code to my Circuit Playground Express one last time, and this is the
result!