Binary display in Scratch

digit sprite

digit sprite

Python was a straightforward input/process/output project, but in Scratch displaying binary numbers can be much more visual.  I found it fairly easy to create once I’d got the basic principles: I used 9 sprites altogether, one for each of the 8 digits and a button which handled most of the actual code.

Each digit sprite has two costumes, one showing 0 and one showing 1.  In fact they have a third, which is the number they represent, but I chose not to continue with the option of displaying that as it would have made the project more complicated and I wanted the first version to be as simple as possible; instead I displayed the value of each digit below it on the background.  Each of these digit sprites responds to three instructions: when Green flag clicked switch to costume zero, when I receive reset switch to costume zero and when I receive [name of digit] on switch to costume one.

button sprite code

button sprite code

The button sprite resets all digits to zero, asks for the number to display, uses a variable to store the answer, then runs through the algorithm to turn the right digits on, broadcasting a message to each digit that needs to be turned on.  The number that is to be displayed is shown at the top of the screen as well.

This project was fun to create, but more complicated than the python version as I had to work out how the sprites would work together to complete the project.  There is also the possibility of becoming distracted by sorting out fancy graphics rather than focusing on pure code, so while I would probably encourage students to play with a finished version and see how it works, I’m not sure I would give it to them as a project for them to create too early on in their learning. as the visual element can distract from the code learning.  On the other hand, it would work well as an extension activity to students who already have experience in Scratch and have learnt the project in a different form.

You can try my project out for yourself on the Scratch website, and download it to look at the code used.  I made this completely in Scratch rather than BYOB, as it did not seem to need any of the extra features.


About emmyleigh
Writer/editor/proofreader who loves technology

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: