Tuesday, September 21, 2021

Fun With Racket: Morse Code

Racket Morse Code

Learning to code with Racket, BSc Computer Science, 2016.   You can find the project by clicking the Github icon. ->GitHub

Introduction


When learning to code, it's always practice... practice... and more practice. Even if it has nothing to do with career development or a project assignment, or simply useful, practice is the most important thing.

To play around with data types in Racket, particularly lists and structs, I set myself a project working with Morse code (because why not), mostly because I could use it on multiple fronts. Text-based output, GUI display, and simple output with the Arduino.



Racket Environment


Racket is a programming language - a dialect of Lisp and a descendant of Scheme. It allows functional programming and other different models and ideas that programmers aren't even aware of. It's not the most infamous when it comes to languages, but it is a great starter and easy-to-build concepts and training.

The environment, Dr. Racket, is quite intuitive and once you get to know it a little better, it can become incredibly easy to understand. It usually works in a read-eval-print loop, or REPL. Imagine your machine just sitting there and waiting for something to read. Once it gets it, it evaluates and then prints the result.

Dr. Racket Environment

Implementation


As mentioned in the Introduction, there were three parts to this so-called "practice" project.

Part I: Text-based (console) output

Experimenting with different data types (sets, arrays, structs, lists), I found out that the best structure for this project is lists - more specifically, nested lists. Using lists to build a dictionary of alphabets and the morse code equivalent, using basic conditionals and loops, I set up the function to translate strings to morse code.

Dictionary of alphabets (nested lists structure)

Console code run

Part II: GUI

With the basics all completed, I further implemented a GUI-based application after covering the lessons during university classes. I added a little Disney magic to it because I practically live and breathe Disney.

Using black and red square images, and some blink code to change the images to blink 1 second and 2 seconds for dots and dashes respectively,  I managed to "animate" a sequence based on user input.

Racket GUI: Black square blinks

Part III: Arduino

Finally, I wanted to test my hardware knowledge. I'm not the biggest fan of dealing with hardware but might as well make it something that I was interested in. It didn't take much coding to get the setup done as I already had the base functions down.

After connecting to the GUI, based on user input, the bulb (connected to Arduino) would blink to match the GUI.


Evaluation




Final video project: GlobAR



0 comments:

Post a Comment




 
Loading...