5
Ozobot Bit Morse Code Generator Created by Richard Born Associate Professor Emeritus Northern Illinois University [email protected] Topics Computer Science, Functions, Visual block programming Ages Grades 9-12 Duration Intended as a homework assignment; 1-2 hours O Z O B O T S T R E A M APPROVED APPROVED

Challenge Lesson - Ozobot Bit Morse Code Generator · what has become known as the Morse code, named after Samuel Morse, inventor of the land-line telegraph system back in 1837. SOS

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Challenge Lesson - Ozobot Bit Morse Code Generator · what has become known as the Morse code, named after Samuel Morse, inventor of the land-line telegraph system back in 1837. SOS

Ozobot Bit Morse Code Generator

Created by

Richard Born

Associate Professor Emeritus

Northern Illinois University

[email protected]

Topics

Computer Science, Functions,

Visual block programming

Ages

Grades 9-12

Duration Intended as a homework assignment; 1-2 hours

OZO

BOT STREA

M

APPROVED

APPROVED

Page 2: Challenge Lesson - Ozobot Bit Morse Code Generator · what has become known as the Morse code, named after Samuel Morse, inventor of the land-line telegraph system back in 1837. SOS

1

Challenge Lesson:

Ozobot Bit Morse Code Generator

By Richard Born Associate Professor Emeritus

Northern Illinois University [email protected]

Introduction

MosteveryonehasheardoftheinternationaldistresssignalSOS,“SaveOurSouls”:

WiththelettersSandOencodedasaseriesofdots(dit)anddashes(dah),thissignalmakesuseofwhathasbecomeknownastheMorsecode,namedafterSamuelMorse,inventoroftheland-linetelegraphsystembackin1837.SOSisjustoneofmanyabbreviationsusingMorsecodethatareunderstoodinternationally,makingMorsecodeindependentofproficiencyintheEnglishlanguage.

Morsecodehasanumberofuseseventothisday.ItispopularamongamateurradiooperatorsbutisnolongerrequiredforlicensingintheUnitedStatesandmanyothercountries.Itisusedinthemedicalsciencesasanassistivecommunicationtechnologyforpeoplewithseveredisabilities,suchasbeingbothdeafandblind.Amessagethatcanbereadbycomputersistappedorblinkedoutbythepersonwiththedisability.SkinbuzzerscanthenbeusedtoreceiveMorsecodes.TheabilitytosenddistressmessagesoverlargedistancewithrelativelylowpowerrequirementshasmadeMorsecodeusefulinthemilitary.

Morsecodehasseveraladvantagesinadditiontothosesuggestedinthepreviousparagraph.Morsecodecanbereadbyskilledlistenerswithouttheneedforadecodingdeviceofanykind.Morsecodecanalsobetransmittedinavarietyofformsincludingaudiotones,radiosignals,electricalsignals,andvisualsignalssuchasablinkingLED.RadiosignalingofMorsecodeisusuallyinanon-offkeyedmanner,requiringlesscomplexequipmentthanotherradiocommunicationtechnologies.

YoumaybewonderingwhyonewouldwanttodevelopaMorsecodegeneratorforOzobotBit.Themaineducationalpurpose,asseenbytheauthorofthispaper,isthatdoingsopresentsagreatopportunityforthestudenttolearnhierarchicalmodularprogrammingbytheuseoffunctions.Theadvantagesofsuchmodularityincludeeasierprogramming,reductionincodingtime,avoidingrepetitionofcode,easiermaintenanceduetotheabilitytolocateandquicklychangevaluesofparameters,andprogramsthatrequirelessmemory.ReductioninrequiredmemoryforprogramsisparticularlyimportantwhenprogrammingsmalldeviceswithlimitedmemorylikeOzobotBit.

Page 3: Challenge Lesson - Ozobot Bit Morse Code Generator · what has become known as the Morse code, named after Samuel Morse, inventor of the land-line telegraph system back in 1837. SOS

2

MorseCodeStructure

Morsecodesexistforletters,numbers,andspecialcharacters,andincludeabbreviationsforcommonlyusedwords.Figure1showstheInternationalMorsecodesforlettersandnumbers.

Figure1

Thecodingprocessmakesuseofashorttimegapbetweenelementalpartsofthesameletter,alongergapbetweenletters,andanevenlongergapbetweenwords.Supposethatthelengthofadotisonetimeunit.ThentheInternationalTelecommunicationUnion(ITU)definesthefollowingregardingthespacingandlengthofsignals:

• Thelengthofadotisonetimeunit.• Thelengthofadashisthreetimeunits.• Thespacebetweenelementalpartsofthesameletterisonetimeunit.• Thespacebetweenlettersisthreeunits.• Thespacebetweenwordsisseventimeunits.

Withtheaveragelengthofawordbeingsixletters,thefollowingformulagivesagoodapproximationforthetimelength,T,inmilliseconds,ofthetimeunit,assumingthatthegoalisthetransmittalofWwordsperminute(WPM).

𝑇 = 1200𝑊

Forexample,20WPMwouldmeanthatthetimeunitwouldbe60ms.

Page 4: Challenge Lesson - Ozobot Bit Morse Code Generator · what has become known as the Morse code, named after Samuel Morse, inventor of the land-line telegraph system back in 1837. SOS

3

FunctionsfortheOzobotMorseCodeProgram

Figure2showsasuggestedsetofhierarchicaluserdefinedfunctionsforprogrammingOzobotBittoblinktheMorsecode.Thelowestlevelfunctionsareintheleftmostcolumn,withprogressivelyhigherlevelsasonemovestotheright.Anexampleofatypicalmainprogramisshownintherightmostcolumn,whereOZOBOTMYTINYROBOTissettoblink10timesinMorsecode.KeepinmindthatthesuggestedfunctionsarebasedonusingOzoBlocklyblocksavailablein“Advanced”mode4.Capabilitiesof“Master”mode5,withplanstosupportlow-levelcontrolfunctionsandadvancedprogrammingfeatures,areunknowntotheauthoratthewritingofthisdocument.ThesecapabilitiescouldpossiblyresultinadifferentapproachtoprogrammingOzobottoproduceMorsecode.

Figure2

ReferringtoFigure2,thelowestlevelfunction“options”iswherethevaluesofallvariablescontainingnumericconstantsaredeclared.Thisprovidesasinglelocationwhereadjustmentsofthesevaluescanbemade.Forexample,abeginnerwhoislearningMorsecodemaywanttoincreasethetimebetweendotsanddashes,thetimebetweenletters,andthetimebetweenwords.ThisalsoprovidesasinglelocationwherethecolorthatOzobotblinksitsMorsecodecanbeadjustedbysettingthered,green,andbluecomponentsoftheLED’scolor.Suggestedvariableswithconstantvaluesthatcanbedeclared:

Page 5: Challenge Lesson - Ozobot Bit Morse Code Generator · what has become known as the Morse code, named after Samuel Morse, inventor of the land-line telegraph system back in 1837. SOS

4

• Threevariablestoholdthevaluesforthered,green,andbluecomponentsoftheLED’scolor• Twovariablestoholdthenumberoftimeunitsfordotsanddashes• Threevariablestoholdthetimeunitspacingbetweendotsanddashes,betweenletters,and

betweenwords• Avariabletosetthedesiredwordsperminute(WPM)forthegeneratedMorsecode• Avariabletocomputethetimelengthforthebasictimeunit.Keepinmindthatyouwillbe

usingtheOzoBlocklyblock“wait…x10ms”,soyouwillwanttosetthetimeunitto120/WPMratherthan1200/WPMsincetheblockmultipliesx10ms.

YoumayalsofindithelpfulintheoptionsfunctiontoinitiallysettheLEDtowhiteforthreeseconds,andthenturnitOFFforasecondbeforeflashingtheMorsecode.

Movingontothenextcolumnoffunctions,firstconsiderthe“turnLEDon”userdefinedfunction.WhilethereisanOzoBlocklyfunctionto“turnLEDoff”,thereisnoOzoBlocklyblockthatturnstheLEDonwithacolorthatcanvary.However,youcanturntheLEDonbyusingtheOzoBlocklyblock“setLEDcolor”andusethevariablesforred,green,andbluethatyoudefinedintheoptionsfunction.

Theuser-definedfunctions“dotdashspace”,letterspace,andwordspacesimplyturntheLEDoffandthenwaittheappropriatenumberofmilliseconds.

Movingontothenextcolumnofuser-definedfunctions,theuser-definedfunctions“todot”and“todash”,eachcall“turnLEDon”,waittheappropriatenumberofmilliseconds,andtheturnofftheLED.

Movingontothehighestleveluserdefinedfunctions,weseethatthereare26ofthem,oneforeachletterofthealphabet.(YouprobablywillnothaveenoughmemoryinyourOzobotBittoincludethenumbers0through9inyourcodes.)Eachofthese26letterfunctionswillmakeuseofthetwomiddlelevelsofuserdefinedfunctions,accordingtothedefinitionsoftheInternationalMorsecode.

Thatprettymuchsetsthestageforyourprogrammingchallenge.Enjoy!

Ifyou’dliketoseeashortvideooftheOzobotBitMorsecodegeneratorinaction,visitthislinkonYouTube:

https://youtu.be/cUc4m261nXg

Inthisvideo,Ozobot’sblinkingLEDhasbeeninterfacedwithasimplelittleBitscircuitthatconvertstheLEDsignalsfromOzobottosoundsonaspeaker.ThecodedmessageisOzobotMyTinyRobot.Notethatonecouldreplacethespeakerwithavibrationmotor.Thisvibrationmotorcouldbeattachedtoadeafandblindperson’sskin.IfthispersonknowsMorsecode,heorshecouldinterpretthecodethroughthesenseoftouchontheskin.