欢迎来到天天文库
浏览记录
ID:48014715
大小:856.06 KB
页数:11页
时间:2019-07-18
《adafruit-arduino-lesson-13-dc-motors.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、ArduinoLesson13.DCMotorsCreatedbySimonMonkGuideContentsGuideContents2Overview3Parts4Part4Qty4BreadboardLayout6ArduinoCode7Transistors9OtherThingstoDo11©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motorsPage2of11OverviewInthislesson
2、,youwilllearnhowtocontrolasmallDCmotorusinganArduinoandatransistor.YouwilluseanArduinoanalogoutput(PWM)tocontrolthespeedofthemotorbysendinganumberbetween0and255fromtheSerialMonitor.©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motor
3、sPage3of11PartsTobuildtheprojectdescribedinthislesson,youwillneedthefollowingparts.PartQtySmall6VDCMotor1PN2222Transistor11N4001diode1270ΩResistor(red,purple,brownstripes)1Half-sizeBreadboard1©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-
4、13-dc-motorsPage4of11ArduinoUnoR31Jumperwirepack1©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motorsPage5of11BreadboardLayoutWhenyouputtogetherthebreadboard,therearetwothingstolookoutfor.Firstly,makesurethatthetransistoristherightw
5、ayaround.Theflatsideofthetransistorshouldbeontheright-handsideofthebreadboard.Secondlythestripedendofthediodeshouldbetowardsthe+5Vpowerline-seetheimagebelow!ThemotorthatcomeswithAdafruitArduinokitsdoesnotdrawmorethan250mAbutifyouhaveadifferentmotor,itcouldeasil
6、ydraw1000mA,morethanaUSBportcanhandle!Ifyouaren'tsureofamotor'scurrentdraw,powertheArduinofromawalladapter,notjustUSBThemotorcanbeconnectedeitherwayaround.©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motorsPage6of11ArduinoCodeLoadu
7、pthefollowingsketchontoyourArduino./*AdafruitArduino-Lesson13.DCMotor*/intmotorPin=3;voidsetup(){pinMode(motorPin,OUTPUT);Serial.begin(9600);while(!Serial);Serial.println("Speed0to255");}voidloop(){if(Serial.available()){intspeed=Serial.parseInt();if(speed>=0&&
8、speed<=255){analogWrite(motorPin,speed);}}}Thetransistoractslikeaswitch,controllingthepowertothemotor,Arduinopin3isusedtoturnthetransistoronandoffandisgiventhename'motorPin'
此文档下载收益归作者所有
点击更多查看相关文章~~