That's what I'm gonnadoislookatusinganArduinoforthatbecausetheyareDoweknowletsushookitup, Youknow, fromusbetoourcomputer, andthenitgivesus a bunchofdigitaloutputsthatwecanprogram.
I couldcertainlyusethisArduino, youknow, noproblemsthere, but I'm gonnauseinsteadtheArduinoNano, whichhasexactlythesamefunctionality, hasallthesameoutputs.
That's justin a morecompactformfactorhere, whichisreallynicebecauseitwillplugrightintoourbreadboard.
WecompletetheNanodirectlyintobreadboardhere, andthenithas a USBportthatwecanusetoplugitintothecomputer.
Soweneedtobeabletocontrol 21 inputs, essentiallytothe E problem, usingjust 14 datasignalsontheArduino.
Sothatsoundslike a bitof a problem, butButactually, it's worsethanthat, becausethisthese 1st 2 pins T X andRx, youcanonlyusethoseifyou'renotusingtheserialinterfacewiththeUSB.
Andasyou'llsee, wereallywanttousethatserialinterfacebecauseifwewouldhavereadwhat's onthe e problem, wouldbenicetobeabletoreadthedatafromthepromandthensendittothecomputersowecandisplayitonourscreenorsomething.
Andsoif I'm notpushingthisbuttonandtheclockpulses, thenitstores a zero.
If I ampushingthebuttonhereandtheclockpulses, itstores a oneandtheniftheclockpulsesagainand I'm notinputtinganythinghere, itstores a zero.
Butwhatwedowiththeshiftregisteriswetaketheoutputofthat D flipflop, andwehookitintotheinputofanother D flipflopandSowhathappensnowisif I clocktheoneintothis D flipflopthatoneisnowservingistheinputforthenext D flipflop.
You'llnotice I'vealsoconnectedalltheclocksofthese d flipflopstogether.
Andsoonthenextclockpulse, thisonehereistheinputforthenext D flipflop.
Anddoyouseeonthatclockpulsethatonecomesoverhereand I canhookthattoanother D flipfloponthenextclockpulse.
Itmovesoverthere, and I canhavethathookeduptoanother D flipflop.
Andyouknow, I canput a oneinoverhereonthe 1st 1 andyouseethatonegoeshere.
So I'vegoteightstagesessentiallyhookeduphere, butyoucouldhavearbitrarilymanystages, asmanystagesasyouwanthookeduphereandeveryclock, everythingjustmovesdown.
OnestageAndsoyoucanputwhateverdatayouwantintothisthingbyjustcontrollingtheoneinputhereandtheclockso I canputwhatevervalue I wantinhere.
Soif I wanttoput 10101010 intothisshiftregister, I justneedtoclockinthosethosebitssoandclockin a oneandthen a 01010 10 Andnowmyoutputscollectivelyshowthat 10101010 And I wasabletogetthatdataintotheseeightoutputs.
You'vejustusinguswell, really.
Twoinputswiththeoneinthesingleinputandthentheclock, because a shiftregisterhasjust a singleinput.
Butasmanyoutputsasyouwant, it's veryusefulin a casewhere, youknow, likeanArduinowherewehave a limitednumberofoutputpinsandweandweneedmore.
Andsothat's whyshiftregistersactuallyverycommoninArduinoprojectsandoneofthemostcommonshiftregistersitsusesthe 74 h c 595 andit's aneightbitshiftregister, Cyrilinput.
There's eightoutputsthoseairhookeduptotheseladiesandsothatthat's theseightbluewiresthatcomeovertotheladiesandthenthroughtheladiestogroundandthe 74 h c 595 doesn't haveanykindofcurrentlimitingontheoutput.
Theygiveus a taphereforthisthislastbitbecauseifwe'reclockingdatainhere, thatdatafirstgonnagotothisbitandthenit's goingtoshiftitswayalonghereuntilitgetstothislastbitandwanttoabletokeepshiftingitintothenextchip.
But I thinkthat's okay, becausewe'reonlygonnabeusing 11 oftheseoutputsfortheaddresslinesbecausethere's only 11 addresslines, so I'm justgonnahooktheseupinorder.
Soforthat, wecanuseanyoftheseopenoutputsontheir 2nd 74 85 95 So I'm justgonnausethelastbithereisverytopbit, and I'm gonnahookthatupheretoanotherledjustsowecanseewhat's goingonthere.
Sothisisourthisisgonnabeouroutputenableand s.
So I thinkifwe'vegotouraddresslinesandouroutputenable, thenwecandoeverythingelsedirectlyoffoftheArduinobutforoutputenableWe'regonnashiftthatoutatthesametimethatweweshiftoutthisthisthisbitehere, it's gottobepartofthisfirstbitethatweshipshiftoutbecausethat's what's gonnaendupinthis 2nd 74 85 95 Sotodothat, I'm gonnaactuallychangemysetaddressfunctionheretoalsotake a Booleanwithwhat I wantthestatusofoutputunabletobeandthewaythat I'm gonnasetthisistakethethetoppartoftheaddressthatwerealreadyoutputtinganddo a bitwiseorwithanotherexpressionhere, whichisgonnabeconditionalonwhetheroutputenableistrueorfalse.
Soifoutputenableistrue, then I wentoritwithzero, whichisgonnadonothingifyou'resomethingwithzero, yougetwithwhateveryoustartedwith.
Ifit's noifoutputenableisnottrue, ifit's false, then a manoritwithzero x 80 whichisifyouconvertHex 80 intobinary, it's basicallyjustthefirstbitsetSonow I canusethissetaddressfunction.
So I sentmyaddress.
1234 I consentmyoutputunabletotrue.
Sothis I woulddothisif I wantedto.
Let's saywewanttoreadfromaddress.
1234 Wesettheaddress 1234 andwesetoutputunable.
T true.
Sowegoaheadandrunthis.
It's uploadingandnothinghappened.
Butthatmightactuallyberight, becausewhen I setout, putunabletotrue, Thatmeans I wantto.
I wantthe e prontooutputitscontentsand I'llputitscontents.
Andsothoseairon D fivethrough D 12 So I'm gonnamakesomeorcontentshere, sowe'llsayheprom d zeroisonpinfiveandephraim D sevenisonpen 12.
Wecanusetheseconstancedownheresowe'lldo a loop.
Thepainisgoingtogofromactuallytogobackwardsfrom G sevendownto D zeroWell, deckermintpinandwhat I wanttodoisbasicallyreadeachpinandshiftedintosomebitethatwe'regonnakeeptrackof.
Sothisshouldbuildup a bitebyreadingoneonepanat a timeandwhateverweendupwith, indeed, a we'regonnareturnfromthisreallyproblemfunction.
Andsonowinoursetup, whichiswhichgetsrun, youknow, whenweresettheboardorwhenwe, youknow, whenweuploadnewcodetoit, let's do a reedheproblemofaddresszero, andit's gonnareturn a bite.
Sowhatdowedowiththatby?
Sothisiswhy I didn't wanttouse, uh, these 1st 2 datapins.
Becauseifwedon't useusfirsttobaitedpens, thenwecanusetheserialonthisboardtoactuallygetdataoutofthe U.
S.
Besoifwesayserial, beginandthengiveit a speed 57 600 I think, isthedefault.
Sowe'llgowiththat.
Nowwecando a serialprintlineofwhateverwereadfromAddresszero, andthiswillprintittotheserialmonitor.
Andsoif I gototools, serialmonitorthatpullsupthiswindowandanythingthatwedo, theserialprintlinewillshowupinthiswindow.
Andsonowwewanttotaketheactualdataandputthatoutonthe D for D.
Whatisthe D fivethrough d 12 pins?
Sowhat I'lldoiscreate a loopthatjustgoesthroughallofthepinsandjustsetstheappropriateahbitwe'regonnastartit.
Hepromptlyzero, whichremember, ispinfiveandthengoto E promin d sevenandincrementthepineachtime.
Sothere's a loopthroughallofourdatapins, and I wannado a digitalrighttoeachpinwiththephysicallythenextbitofthedata.
Sowhat I candois I cantakethedata, andif I enditwithonethat's basicallygoingtozeroouteverythingbutthebutthelastbitendingthatdatawithoneisjustgonnabasicallypickthelowestbits.
Ifhehassomedatawhen a 10101010 ifyouendthatwithoneremembersallzeroeshere.
Sotheonlyotherthingweneedtodoispulsethatright, EnablepinIfyourememberinouroriginalwehadthisbuttonthatwepushandwehadthisah, pulsegeneratorthingthatwouldgenerate a 600.
Whatever, Nana.
Secondpulse.
Soweneedtodosomethingsimilarnowwithourrightenablepinhere, whichisattractedto D 13.
So I'm gonnacreateanotherconstanthereforrightenableandthat's connectedtopin d 13 pin 13.
EnablepinWeshouldaddanotherdelayinhere s sowecanwaitforfivemillisecondsisjustkindofAhgoodthingtodobeforewegochangingouraddressorchangingourdatatosomethingelsetogivethetheproblem a chancetoactuallygetthedatawritten.
Andthen I guessso.
Theotherthingweneedtodoismakesuresincewe'redoing a righttoourdatapinshere, wewanttomakesureourdatapinsareinoursetforoutput.
Becauseifwe'rewritingtotheproblem, wewanted a defensetobeoutput.