资源描述:
《单片机教程实战 蜂鸣器唱歌(scm tutorial, combat buzzer singing)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、单片机教程实战2蜂鸣器唱歌(SCMtutorial,Combat2buzzersinging)Thisarticleiscontributedby009refugeesDOCdocumentsmayexperiencepoorbrowsingontheWAPside.ItisrecommendedthatyoufirstselectTXT,ordownloadthesourcefiletothelocalview.SCMtutorial,Combat2buzzersingingRelease:2009-11-0409:01
2、Author:
3、ordinary
4、source:network
5、view:189Theuseofsingle-chipmicrocontroller(orSBC)musicisprobablyoneoftheradioenthusiastsinterestedinproblems.Inthispaper,thebasicsingle-chipmicrocomputerexperimentbetweenthestartingpoint,talkabouttheprinciplesofmusicprogrammingprinciples,procedures
6、,designprinciples,andgivesspecificexamplesforreference.Thebasicpronunciationexperimentalprogramdesignprincipleofsingle-chipweknowthatthesoundfrequencyrangeofabouttenstothousandsofHertz,ifcanusetheprogramtocontrolthesinglemachineofalineof"high"levelorlowlevel,inthemouthoft
7、helinewillbeabletoproduceacertainfrequencysquarewavefrequency,connectedtothespeakerscansendcertainthefrequentrateofvoice,iftheuseofdelaytimecontrolprogramfor"high"and"low"level,canchangetheoutputfrequency,thuschangingthetone.Forexample,toproduce200HZaudiosignals,according
8、tofigure1(ifthetemporaryaccesshornexperiment,canalsobedirectlyconnectedtoP1portinthehornline),theexperimentalprocedureis:thesubroutineDELdelaysubroutine,whenR3is1,thedelaytimeisabout20us,R3storedinthe200HZaudiodelayconstant.Thecycleis1/200,whichis5msseconds.Thus,whentheP1
9、.4highorlowdurationis2.5ms,orthetimeconstantofR3takes2500/20=125(7DH),the200HZtonecanbeemitted.TypetheprogramintothelearningmachineandconstantlymodifytheR3constanttofeelthechangeinpitch.Inmusic,eachnotecorrespondstoadefinitefrequency.Table1givesthenotesandtheircorrespondi
10、ngtimeconstantsattheCtone.AccordingtotheconstantsprovidedinTable1,thereadercansendhis16decimalcodetoR3andpracticeitrepeatedly.Accordingtotable1,thenotescanbeplayed.That'snotenough.Onemustaccuratelycontrolthetempoofapieceofmusic,thatis,thedurationofanote.WecanusethetimerT0
11、tocontrolthetempoofthenoteandsenddifferentinitialvaluestoproducedifferenttimingtimes.Justasthete