You are on page 1of 12

UltrasonicTouchGuitarNXT

Overview
Challenge Usingoneultrasonicsensor,twotouchsensors,andtheNXTbuttons,buildand programaguitarwithanNXTbrickasitsbaseelement.Usethetouchsensorsto raiseandlowerthesoundoneoctaveeach,usethebuttonsontheNXTto controltheemissionofsounds,andlettheultrasonicsensorcontrolthepitchof thesoundcreated. AgeRange 1518 Topics Buttons TouchSensors UltrasonicSensors Subjects Math&Science Music ProgrammingThemes Logic MathematicalManipulationofData Loops Switches,NestedSwitches RelatedMath&ScienceConcepts Ultrasound SoundWaves

BuildingandProgramming
Materials NXTbrick TouchSensorsx2 UltrasonicSensor NXTUltrasonicTouchGuitar(seeUltrasonic_Touch_Guitar_Instructions.pdf) BuildingInstructions 1. BuildanUltrasonicTouchGuitar (SeeUltrasonic_Touch_Guitar_Instructions.pdf) 2. Connectonetouchsensoreachtoports1and4ofanNXTbrick. 3. Connectoneultrasonicsensortoport2oftheNXTbrick.

ProgrammingInstructions UsingMindstormsNXTG,programtheguitartoplaynoteswhentheNXTbricks buttonsarepressed(left,right,andenter,inanycombination).Thepitchofthenote emittedwillbedeterminedusingthedistancefromtheultrasonicsensortoa movingbarrieronthefretboardoftheguitar.Thispitchcanbeshiftedupanoctave (twicethefrequencyoftheoriginalnote)bypressingonetouchsensor,anddown anoctave(halfthefrequencyoftheoriginalnote)bypressingtheothertouch sensor. 1. Startwithaninfiniteloopwithaswitchinside,settobecontrolledbylogic.Place aSoundblockontheswitchsfalse,orlower,path,settostopallsound.

2. AddanNXTButtonsblock,settotheLeftbutton,whenpressed.Addanother NXTButtonsblock,settoEnterbutton,whenpressed.AddaLogicblockset toOr,andwireinthetrue/falseoutputofbothNXTButtonsblockstoinputsA andBofthelogicblock.

3. InsertathirdNXTButtonsblockafterthelogicblockyoujustadded.Setthis NXTButtonsblocktotheRightbutton,whenpressed.AddanotherLogic blockafterthisNXTButtonsblock,settoOr.Wireinthetrue/falseoutput fromtheRightbuttonNXTButtonsblocktoinputAontheLogicblock.Wire theresultfromthefirstLogicblocktoinputBofthesecondLogicblock. Then,wiretheresultfromthesecondLogicblocktotheswitchsinput.

4. Ontheswitchstrue,orupper,beam,addaTouchSensorblocksettoport1, whenpushed.AddasecondTouchSensorblocksettoport4,whenpushed. AddaLogicblocksettoXor.Wirethetrue/falseoutputsofbothTouch SensorblockstoinputsAandBoftheXorLogicblock.

5. AddalogicswitchaftertheXorLogicblock.Thisisthefirstnestedswitch.Wire theresultoftheXorLogicblocktothenestedswitchsinput.Onthenested switchsfalse,orlower,path,addanUltrasonicSensorblock,settoport2., withdistanceunitsofcentimeters.AddaMathblock,settoMultiplication withvalueA=160.WirethedistanceoutputfromtheUltrasonicblocktoinput BoftheMathblock.AddaSoundblockaftertheMathblock,settoplaya Tone,volume75,for0.5seconds,withtheWaitforCompletionboxunchecked.

6. Onthefirstnestedswitchstrue,orupper,path,placeatouchsensorswitch, port1,whenpressed.Thisisthesecondnestedswitch.Onthesecondnested switchsfalsepath,placeanUltrasonicSensorblock,settoport2,distance measuredincentimeters.AddaMathblock,settoMultiplication,valueA= 160.WirethedistanceoutputoftheUltrasonicSensorblocktoinputBofthe Mathblock.AddanotherMathblock,settoMultiplication,valueB=2.Wire intheresultofthefirstMathblocktoinputAofthesecondMathblock.(You couldcombinethemathblockstoonesingleblockwithasetinputof320,but forclarity,theblockswereleftseparate.)AddaSoundblock,settoplayatone for0.5seconds,volume75,withWaitforCompletionunchecked.

7. Onthesecondnestedswitchstruepath,placeanUltrasonicSensorblock,set toport2,distancemeasuredincentimeters.AddaMathblock,setto Multiplication,valueA=160.WirethedistanceoutputoftheUltrasonic SensorblocktoinputBoftheMathblock.AddanotherMathblock,setto Division,valueB=2.WireintheresultofthefirstMathblocktoinputAofthe secondMathblock.(Youcouldcombinethemathblockstoonesingleblock withasetinputof80,butforclarity,theblockswereleftseparate.)Adda Soundblock,settoplayatonefor0.5seconds,volume75,withWaitfor Completionunchecked.

Thefinal,overallschematicoftheprogramisgivenbelow,forcoherence:

InAction
SetuptheinstrumentbyholdingtheNXTbrickinyourlefthand(orstrumming guitarhandifyourelefthanded,youmaywishtouseyourrighthandforthispart) andholdingthemovingplatformonthefretboardinyourotherhand.Holdthe movingplatformwithyourfingerscurledoverthetouchsensorsforbettercontrol. Toplaytheinstrument,soundsaretriggeredwhenoneormoreoftheLeft, Right,orEnterbuttonsontheNXTbrickarepressedwiththestrumminghand.Thepitch outputbytheinstrumentcanbecontrolledbyslidingthemovingplatformwiththe frettinghandupanddownthefretboard.Thebuttonsonthemovingplatformcanbe pressedandheld,oneatatime,toincreaseordecreasethepitchbyanoctave(afactor of2),dependingonwhichbuttonispressed.Ifbothbuttonsarepressed,thenetchange inpitchiszero(sinceanynumbernx2/2=n,theoriginalpitchgenerated). Formorevariety,changethevaluesintheMathblocksandchangethe durationofthesoundintheplayingSoundblock.Seeifthesoundcanbecome smootherormoresteppedsounding(i.e.thereisalotofzippernoiseduetothe quantizationofpitchvaluesandthereforethesounddoesnotseemsmoothtotheear). Changetheoctavebuttonstoincreaseordecreaseby2octavesatatime(pitchvaluex 4orpitchvalue/4),orevenallowforincreaseinoctavebybumpingatouchswitch repeatedly(onebumpup=pitchx2,or1octaveup;twobumpsup=pitchx4,or2 octavesup,etc).

Resources/Help
RelatedActivities UltrasonicTheremin MusicBox LEGORCXPiano Building&ProgrammingReferences TheNXT Ultrasonic_Touch_Guitar.rbt KnowledgeBase WhataresomepossibleusesfortheNXTtouchsensor?HowdoIprogramitwith NXTG? WhatistheNXTGswitchblockfor? HowdoIcreatealoopinNXTGsothatIcanrepeatonesequenceofeventsover andover? WhywouldIneedtouselogicinputsandoutputsinNXTG?Whatisanexample ofaprogramthatuseslogicinputsandoutputs?

ClassroomManagement
Procedure 1. Beginthelessonwithadescriptionofhowultrasonicandtouchsensingworks. AnintroductoryapproachmightbetoexplainthattouchsensingwiththeNXT sensorworksbasedonwhetherornotthebuttonispressed,outputtingalogical 0or1dependingonstate(inNXTG,thetruestateisselectedwithradiobuttons ontheTouchSensorblockeitherwhenpressed,released,orbumped). Ultrasonicsensingcanbelikenedtotheecholocatingabilityofbatsand submarines,merelyapropogationofawaveformthatisthenreflectedbackto thesource.Thetimebetweentheemissionofthewaveanditsreturnyieldsthe distance.Moreadvancedclassescanbetaughttheelectronicsofresistorsand thephysicsofultrasoundbasically,thatvelocityofthewaveemittedmultiplied bythetimeittooktoreflect,whendividedinhalf,yieldsthedistancetheobject isfromthesource: [velocity(m/s)timeelapsed(s)]2=distance(m)toreflectivesurface Electronicinstruments,especiallytheelectricguitarandbass,canalsobe includedinthisintroductoryperiod,withthepotentialadditionofhowthe electronicsintheseinstrumentswork.Thisisespeciallyhelpfulforteaching electromagnetictheoryusingvarioustypesofpickupsinaguitarorbassas examples.Perhapsagoodactivitytocompletebeforehand,oratthestartofthis explanation,wouldbetobuildanddescribetheworkingsofenelectromagnet, asthepickupsinanelectricguitarorbassworkessentiallyasreverse electromagnets. 2. EachstudentorgroupofstudentsshouldhaveanNXTbrickwithallparts necessarytocreateanultrasonictouchguitarasdetailedinthiscoursepack,as wellastwotouchsensors,anultrasonicsensor,andthreeconnectingcords. 3. Eachstudentorgroupofstudentsshouldconstructtheultrasonictouchguitar, attachonetouchsensoreachtoports1and4oftheNXTbrick,andattachthe ultrasonicsensortoport2oftheNXTbrick. 4. HaveeachstudentorgroupofstudentsprogramtheirNXTbrickseitherusing theinstructions,orontheirowniftheyarereadyforthechallenge. (Alternatively,theNXTbrickscanbepreloadedwiththeUltrasonicTouchGuitar programtosavetime,ifprogrammingequipmentisnotreadilyavailable,orto accommodateyoungerclasses.) 5. Havestudentsexperimentwiththeinstrument,makingchangestotheprogram astheygoifpossible.

6. Collaborateasaclassandcompilealistofchangesthatmightbehelpfultothe program,changingthequalitiesofthesoundemitted.Forexample,howcanthe instrumentbeprogrammedtoplayonlyinmusicalhalfsteps,wholesteps,or octaves?Howcanthesmoothestsoundgradientbeobtainedwhenmovingthe platformacrossthefretboard?Doeschangingthesurfaceofthemoving platformfacingtheultrasonicsensor,perhapsbyattachingpaper,plastic,wood, ormetal,createmorecontroloverthepitchoftheinstrument?Isiteasiertouse ahandinfrontoftheultrasonicsensorthantousethemovingplatform? 7. Tryoutsomeideasiftheclassismotivatedandableto,orwrapupbytalking abouttheactivityandadditionalusesofultrasonicandtouchsensingsystems. Electronicinstrumentsandtheirdesignandusagecanalsobediscussedand exploredfurther.Additionalmusicalinstrumentbuildingsessionscanbeheldas ameansofprogressivelearning. Worksheets&Handouts 1. UltrasonicTouchGuitarBuildingInstructions [Ultrasonic_Touch_Guitar_Instructions.pdf]

You might also like