Serial LCD initialize PIN15 ▾baud2400 ▾Serial LCD commandclear screen ▾Serial LCD commandbacklight on ▾100pause (ms)run function “Initialize”addcomment ▾Run "my function" in new cog to handle peizorun function “my function”new processorfunctionaddcomment ▾*** Main Loop ***addcomment ▾Reads Ping, computes digits, calls digit printerrepeatforever ▾doPing))) distance ininches ▾PIN16 ▾inchPing ▾=× ▾÷ ▾inchPing ▾100012ftx1k ▾=÷ ▾ftx1k ▾1000dispFeet ▾=% (remainder after division) ▾× ▾÷ ▾ftx1k ▾1000121000dispInch ▾=50pause (ms)0feet_OR_inch ▾=dispFeet ▾digitPrint ▾=addcomment ▾Call "printDigit" to display feet on LCDrun function “printDigit”11feet_OR_inch ▾=dispInch ▾digitPrint ▾=addcomment ▾Call "printDigit" to display inches on LCDrun function “printDigit”functionprintDigit addcomment ▾This sub prints single digit on LCD and needs:addcomment ▾ digitPrint - the single digit to be printedaddcomment ▾ feet_OR_inch - value of 0 is feet; 11 is inchesaddcomment ▾ addcomment ▾Example Digit: '3'addcomment ▾# #addcomment ▾# # #addcomment ▾# # #addcomment ▾#########addcomment ▾In Binary representation:addcomment ▾100000001addcomment ▾100010001addcomment ▾100010001addcomment ▾111111111addcomment ▾In Decimal Represenationaddcomment ▾257addcomment ▾273addcomment ▾273addcomment ▾511digitPrint ▾0< ▾ifdo0digitPrint ▾=digitPrint ▾10≥ ▾ifdoaddcomment ▾This usage of Case is clunky - but it's the onlyaddcomment ▾way to handle a 2 dimensional array in Blockly031repeatRow ▾fromthru ▾bydoswitchcasedo (then break✓)casedo (then break✓)casedo (then break✓)casedo (then break✓)Row ▾0arrayDigitRow0 ▾elementdigitPrint ▾digitRowNow ▾=1arrayDigitRow1 ▾elementdigitPrint ▾digitRowNow ▾=2arrayDigitRow2 ▾elementdigitPrint ▾digitRowNow ▾=3arrayDigitRow3 ▾elementdigitPrint ▾digitRowNow ▾=Row ▾feet_OR_inch ▾081arraybitLoc ▾elementitem ▾digitLoc ▾digitRowNow ▾& (bitwise AND) ▾ifdoelsecurrentBit ▾0= ▾“ ”Serial LCD print text “#”Serial LCD print text currentBit ▾=digitLoc ▾=repeatitem ▾fromthru ▾bydoSerial LCD set cursor rowcolumn11digitPrint ▾=function printDigit add co...functionmy function addcomment ▾This subroutine take the latest Ping reading addcomment ▾ which is in "inchPing" and adjustsaddcomment ▾the frequency and duration of the addcomment ▾peizo beep. As distance get short,addcomment ▾beep tone gets higher and fasteraddcomment ▾This routine needs to be in seperateaddcomment ▾cog and drive independant peizoaddcomment ▾(as opposed to peizo on the LCD)addcomment ▾because at the fast cycle, it is tooaddcomment ▾fast for the Ping/LCD cycle rate.repeatforever ▾doinchPing ▾mapwith range0(from A)48(from B) to range75(to A)800(to B)cycleTime ▾cycleTime ▾250lowest ▾ofandcycleTime ▾=inchPing ▾mapwith range0(from A)75(from B) to range1000(to A)500(to B)freqNow ▾=inchPing ▾73< ▾frequency PIN17 ▾duration (ms)frequency (Hz)cycleTime ▾freqNow ▾cyclePause ▾pause (ms)ifdocyclePause ▾=cycleTime ▾=function my function add c...functionInitialize array fillbitLoc ▾with values1, 2, 4, 8, 16, 32, 64, 128, 256array fillDigitRow3 ▾with values511, 0, 497, 257, 31, 287, 511, 1, 511, 287, 0, 0array fillDigitRow2 ▾with values257, 258, 273, 273, 16, 273, 273, 1, 273, 273, 0…array fillDigitRow1 ▾with values257, 511, 273, 273, 16, 273, 273, 1, 273, 273, 0…array fillDigitRow0 ▾with values511, 256, 287, 511, 511, 497, 497, 511, 511, 511…array initializeDigitRow3with12elementsarray initializeDigitRow2with12elementsarray initializeDigitRow1with12elementsarray initializeDigitRow0with12elementsaddcomment ▾Each character is made up of 4 Rows and 9 bitsarray initializedigitDefwith12elementsaddcomment ▾temporary - delete this array laterarray initializebitLocwith9elementsaddcomment ▾Used in Bit-AND to pull each bit from digit arrayaddcomment ▾Array bitLoc is 9 number; powers of 2 from 0 to 8function Initialize add co...Parallax BlocklyProp ProjectUser: offlineTitle: Social dist mon SWays -v4Project ID: 0Device: otherDescription: inchPingftx1kdispFeetcycleTimedispInchcyclePausefeet_OR_inchfreqNowdigitPrintRowdigitRowNowitemdigitLoccurrentBitInitializeCOMMENTArray bitLoc is 9 number; powers of 2 from 0 to 8COMMENTUsed in Bit-AND to pull each bit from digit arraybitLoc9COMMENTtemporary - delete this array laterdigitDef12COMMENTEach character is made up of 4 Rows and 9 bitsDigitRow012DigitRow112DigitRow212DigitRow312bitLoc1, 2, 4, 8, 16, 32, 64, 128, 256DigitRow3511, 0, 497, 257, 31, 287, 511, 1, 511, 287, 0, 0DigitRow2257, 258, 273, 273, 16, 273, 273, 1, 273, 273, 0, 511DigitRow1257, 511, 273, 273, 16, 273, 273, 1, 273, 273, 0, 0DigitRow0511, 256, 287, 511, 511, 497, 497, 511, 511, 511, 0, 5111524001217100COMMENTRun "my function" in new cog to handle peizoCOMMENT*** Main Loop ***COMMENTReads Ping, computes digits, calls digit printerFOREVERinchPing_inches16ftx1k * / inchPing100012dispFeet / ftx1k1000dispInch % * / ftx1k100012100050feet_OR_inch0digitPrintdispFeetCOMMENTCall "printDigit" to display feet on LCDfeet_OR_inch11digitPrintdispInchCOMMENTCall "printDigit" to display inches on LCDmy functionCOMMENTThis subroutine take the latest Ping reading COMMENT which is in "inchPing" and adjustsCOMMENTthe frequency and duration of the COMMENTpeizo beep. As distance get short,COMMENTbeep tone gets higher and fasterCOMMENTThis routine needs to be in seperateCOMMENTcog and drive independant peizoCOMMENT(as opposed to peizo on the LCD)COMMENTbecause at the fast cycle, it is tooCOMMENTfast for the Ping/LCD cycle rate.FOREVERcycleTime04875800inchPingcyclePausecycleTimecycleTime < cycleTime250freqNow0751000500inchPing<inchPing7317cycleTimefreqNowcyclePauseprintDigitCOMMENTThis sub prints single digit on LCD and needs:COMMENT digitPrint - the single digit to be printedCOMMENT feet_OR_inch - value of 0 is feet; 11 is inchesCOMMENTCOMMENTExample Digit: '3'COMMENT# #COMMENT# # #COMMENT# # #COMMENT#########COMMENTIn Binary representation:COMMENT100000001COMMENT100010001COMMENT100010001COMMENT111111111COMMENTIn Decimal RepresenationCOMMENT257COMMENT273COMMENT273COMMENT511<digitPrint0digitPrint0>=digitPrint10digitPrint11COMMENTThis usage of Case is clunky - but it's the onlyCOMMENTway to handle a 2 dimensional array in BlocklyRow= 031TRUETRUETRUETRUERow0digitRowNowDigitRow0digitPrint1digitRowNowDigitRow1digitPrint2digitRowNowDigitRow2digitPrint3digitRowNowDigitRow3digitPrintRowfeet_OR_inchitem= 081digitLocbitLocitemcurrentBit & digitLocdigitRowNow==currentBit0 #000000000000