Zum Inhalt springen

Projekte

#11 Morse Code Cryptography With micro:bit

von PicoBricks Team 08 May 2025

People sometimes utilize some passwords to protect their physical belongings or written/visual content. The diversity of symbols used in passwords contributes to the strength of the password. Similarly, not using easily guessable personal data in passwords will enhance the strength of your password.

Cryptography refers to the processes that render readable data incomprehensible to unauthorized individuals.

In Morse Code, there are distinct long and short signals corresponding to each letter. Each character of the text to be encrypted is encoded using the short and long signals in Morse Code. When these signals are combined as a whole and deciphered, the encrypted text is revealed. The long and short signals in Morse Code can be created using sound or light. The most well-known example of this is the SOS distress signal. With a flashlight or similar light source, a call for help can be made by sequentially emitting three long, three short, and three long signals. This is because in Morse Code, the letter "s" is represented by (...) three short signals, and the letter "o" is represented by (---) three long signals.

Morse Code Alphabet

In this project, we will encrypt the specified text by using Morse Code within the code, utilizing the PicoBricks RGB LED module. Each character of the encrypted text will be displayed on the Micro:Bit matrix LED, and its Morse Code equivalent will be shown on the PicoBricks OLED screen.

Connection Diagram:

You can prepare this project without making any cable connections.


Project Images:

 

MakeCode Code of The Project


Python Code of The Project:

#Morse Code Cryptography
from microbit import *
from picobricks import *
import neopixel

# Pin Initialization
RGB_Pin = pin8
Num_Leds = 3

# Function Initialization
oled = SSD1306()
oled.init()
oled.clear()
np = neopixel.NeoPixel(RGB_Pin, Num_Leds)

#Neopixel
np[0] = (0, 0, 0)
np[1] = (0, 0, 0)
np[2] = (0, 0, 0)
np.show()

morse = ['.-','-...','-.-.','-..','.','..-.','--.','....','..',
         '.---', '-.-','.-..','--', '-.','---', '.--.', '--.-',
         '.-.', '...','-','..-', '...-', '.--','-..-', '-.--',
         '--..', '.----','..---','...--','....-','.....', '-....',
         '--...','---..', '----.','-----']

alphabet = ['a','b','c','d','e','f','g','h','i',
         'j', 'k','l','m', 'n','o', 'p', 'q',
         'r', 's','t','u', 'v', 'w','x', 'y',
         'z', '1','2','3','4','5', '6',
         '7','8', '9','0']

#print(len(alphabet))                
while True:
    if button_a.is_pressed():
        passwordText="picobricks"
        for i in range((len(passwordText))):
            oled.clear()
            oled.add_text(0,0,str(passwordText))
            display.show(passwordText[i])
            oled.add_text(0,1,str(morse[alphabet.index(passwordText[i])]))

            j=0
            for j in range(len(morse[alphabet.index(passwordText[i])])):
                oled.add_text(0,2,str(morse[alphabet.index(passwordText[i])][j]))
                if morse[alphabet.index(passwordText[i])][j] == '.' :
                    np[0] = (255, 255, 255)
                    np[1] = (255, 255, 255)
                    np[2] = (255, 255, 255)
                    np.show()
                    sleep(500)
                else:
                    np[0] = (255, 255, 255)
                    np[1] = (255, 255, 255)
                    np[2] = (255, 255, 255)
                    np.show()
                    sleep(1500)
                np[0] = (0, 0, 0)
                np[1] = (0, 0, 0)
                np[2] = (0, 0, 0)
                np.show()
                sleep(100)

MicroBlocks Code of The Project

 

Vorheriger Beitrag
Nächster Beitrag

Danke fürs Abonnieren!

Diese E-Mail wurde registriert!

Shoppen Sie den Look
Wählen Sie Optionen

Bearbeitungsoption

Benachrichtigung wieder auf Lager

Vergleichen

Produkt ArtikelnummerBewertungBeschreibung Sammlung Verfügbarkeit Produktart Andere Details
this is just a warning
Anmeldung
Einkaufswagen
0 Artikel
Same Day Shipping No Extra Costs
Easy Returns Guarantee Return with Ease
Secure Checkout Secure Payment