adafruit-arduino-lesson-5-the-serial-monitor.pdf

adafruit-arduino-lesson-5-the-serial-monitor.pdf

ID:48014712

大小:430.80 KB

页数:11页

时间:2019-07-18

adafruit-arduino-lesson-5-the-serial-monitor.pdf_第1页
adafruit-arduino-lesson-5-the-serial-monitor.pdf_第2页
adafruit-arduino-lesson-5-the-serial-monitor.pdf_第3页
adafruit-arduino-lesson-5-the-serial-monitor.pdf_第4页
adafruit-arduino-lesson-5-the-serial-monitor.pdf_第5页
资源描述:

《adafruit-arduino-lesson-5-the-serial-monitor.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、ArduinoLesson5.TheSerialMonitorCreatedbySimonMonkGuideContentsGuideContents2Overview3TheSerialMonitor4ArduinoCode7OtherThingstoDo10©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitorPage2of11OverviewInthislesson,youwillbuildonlesson4,addingthefacilityto

2、controltheLEDsfromyourcomputerusingtheArduinoSerialMonitor.Theserialmonitoristhe'tether'betweenthecomputerandyourArduino-itletsyousendandreceivetextmessages,handyfordebuggingandalsocontrollingtheArduinofromakeyboard!Forexample,youwillbeabletosendcommandsfromyourcomputertoturnonLEDs.Inthisle

3、sson,youwilluseexactlythesamepartsandasimilarbreadboardlayoutasLesson4.So,ifyouhavenotalreadydoneso,followlesson4now.©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitorPage3of11TheSerialMonitorUploadthefollowingsketchtoyourArduino.Lateron,wewillseeexact

4、lyhowitworks./*AdafruitArduino-Lesson5.SerialMonitor*/intlatchPin=5;intclockPin=6;intdataPin=4;byteleds=0;voidsetup(){pinMode(latchPin,OUTPUT);pinMode(dataPin,OUTPUT);pinMode(clockPin,OUTPUT);updateShiftRegister();Serial.begin(9600);while(!Serial);//WaituntilSerialisready-LeonardoSerial.pri

5、ntln("EnterLEDNumber0to7or'x'toclear");}voidloop(){if(Serial.available()){charch=Serial.read();if(ch>='0'&&ch<='7'){intled=ch-'0';bitSet(leds,led);updateShiftRegister();Serial.print("TurnedonLED");Serial.println(led);}if(ch=='x'){leds=0;updateShiftRegister();Serial.println("Cleared");}}}voi

6、dupdateShiftRegister(){digitalWrite(latchPin,LOW);shiftOut(dataPin,clockPin,LSBFIRST,leds);digitalWrite(latchPin,HIGH);}©AdafruitIndustrieshttp://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitorPage4of11AfteryouhaveuploadedthissketchontoyourArduino,clickontheright-mostbuttono

7、nthetoolbarintheArduinoIDE.Thebuttoniscircledbelow.Thefollowingwindowwillopen.ThiswindowiscalledtheSerialMonitoranditispartoftheArduinoIDEsoftware.ItsjobistoallowyoutobothsendmessagesfromyourcomputertoanArduinoboard(overUSB)andalsotoreceivemessagesfromth

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
相关文章
更多
相关标签