Arduino uno的制作与调试
- 格式:doc
- 大小:8.71 MB
- 文档页数:24
arduino土壤湿度传感器实训报告一、实训目的1. 学习Arduino土壤湿度传感器的工作原理和接线方式。
2. 掌握Arduino编程技巧,实现土壤湿度的实时监测。
3. 培养实际动手能力和团队协作能力。
二、实训设备与材料1. Arduino UNO开发板2. 土壤湿度传感器3. 电阻、电容、晶体管等电子元件4. 杜邦线、面包板等实验工具5. 计算机及Arduino IDE软件三、实训内容与步骤1. 土壤湿度传感器简介了解土壤湿度传感器的工作原理、功能特点和技术参数。
2. 接线与硬件搭建根据传感器说明书,将土壤湿度传感器与Arduino UNO开发板连接。
一般需要连接VCC、GND、模拟输出(AO)和数字输出(DO)等引脚。
3. 编写Arduino程序使用Arduino IDE编写程序,实现以下功能:a. 读取土壤湿度传感器的模拟输出值。
b. 将模拟值转换为土壤湿度百分比。
c. 通过串口通信将土壤湿度值发送到计算机。
d. 设计一个简易的浇水控制系统,当土壤湿度低于设定值时,开启浇水装置;当土壤湿度高于设定值时,关闭浇水装置。
4. 调试与优化上传程序到Arduino UNO开发板,观察土壤湿度传感器的工作情况。
根据实际情况调整程序,优化浇水控制系统的性能。
5. 实训总结总结本次实训的学习内容,分享实训过程中的心得体会和经验教训。
四、实训成果与评价1. 成果展示:完成土壤湿度传感器的接线、编程和调试,实现实时监测和自动浇水功能。
2. 评价标准:a. 硬件搭建是否正确、稳固。
b. 程序编写是否规范、高效。
c. 系统功能是否完善、可靠。
d. 团队协作和沟通能力。
五、实训建议1. 在实际操作过程中,注意安全,避免触电等意外事故。
2. 仔细阅读传感器说明书,确保正确接线。
3. 编写程序时,注重代码的可读性和可维护性。
4. 调试过程中,耐心观察现象,分析问题,逐步解决。
5. 加强团队协作,共同完成实训任务。
六、拓展与应用1. 尝试使用其他类型的土壤湿度传感器,比较其性能差异。
第2章ArduinoUNO板结构说明Arduino UNO板结构说明如图所⽰,Arduino UNO板结构说明图!如果你想⽤Arduino UNO板,玩⼀些⼩创意,这个⼀定要知道。
造物精神的核⼼是,有想法,⽽且要有⾏动⼒。
本⽂就⽤这⼀张图了,标志出来,读者⾃⼰找,印象更深刻!1、电源USBArduino板通过计算机上的USB线供电。
2、电源(桶插座)Arduino板通过它直接从交流电源供电。
3、稳压器稳压器控制提供给Arduino板的电压,稳定处理器和其他元件使⽤直流电压。
4、晶体振荡器Arduino使⽤晶体振荡器处理时间问题。
Arduino晶体顶部打印的数字说明频率。
5、Arduino重置(1)复位按钮。
(2)RESET引脚。
6、供电引脚3.3V引脚提供3.3输出电压。
5V引脚提供5输出电压。
GND引脚接地。
Vin引脚从外部电源为Arduino板供电。
7、模拟引脚六个模拟输⼊引脚从A0到A5。
从模拟传感器读取信号,转换成微处理器可读取的数字值。
8、微控制器微控制器从Arduino IDE加载新程序之前,须知IC。
9、ICSP引脚ICSP是Arduino的微型编程头。
输出的“扩展”。
将输出设备从属到SPI总线的主机。
10、电源LED指⽰灯指⽰灯应亮起,表明电路板已正确通电11、TX(发送)和RX(接收)(1)在数字引脚0和1处,指⽰引脚负责串⾏通信。
(2)TX和RX LED。
发送串⾏数据时,TX LED以不同的速度闪烁。
闪烁速度取决于板所使⽤的波特率。
RX在接收过程中闪烁。
12、数字I/O引脚Arduino UNO板有14个数字I/O引脚,6个提供PWM(脉宽调制)输出。
13、AREF模拟参考设置外部参考电压(0⾄5伏之间)作为模拟输⼊引脚的上限。
第1篇一、案例背景随着科技的飞速发展,物联网技术逐渐渗透到人们生活的方方面面。
智能家居作为物联网的重要应用领域,已经成为人们追求高品质生活的重要方向。
本案例旨在通过Arduino平台,让学生掌握基本的电子电路知识、编程技能以及物联网技术,设计并实现一个简单的智能家居系统。
二、教学目标1. 理解智能家居系统的基本原理和组成。
2. 掌握Arduino编程语言的基本语法和编程技巧。
3. 熟悉电子元器件的使用和电路连接方法。
4. 培养学生的创新意识和团队协作能力。
三、教学内容1. 智能家居系统概述- 介绍智能家居系统的定义、发展历程和分类。
- 分析智能家居系统的基本组成和功能模块。
2. Arduino编程基础- 学习Arduino开发环境搭建。
- 掌握Arduino编程语言的基本语法和编程技巧。
- 熟悉Arduino库函数的使用。
3. 电子元器件与电路- 认识常用电子元器件,如电阻、电容、二极管、三极管等。
- 学习电路原理图绘制和电路板焊接。
- 掌握电路调试和故障排除方法。
4. 物联网技术- 介绍物联网的基本概念和技术架构。
- 学习Wi-Fi、蓝牙等无线通信技术。
- 掌握物联网设备的数据传输和处理。
5. 智能家居系统设计- 分析智能家居系统的需求,确定系统功能和模块。
- 设计系统架构,包括硬件和软件部分。
- 编写程序,实现系统功能。
- 调试和优化系统。
四、教学过程1. 理论教学- 利用PPT、视频等多媒体手段进行理论讲解。
- 结合实际案例,引导学生分析问题、解决问题。
2. 实践操作- 学生分组,每组完成一个智能家居系统的设计与实现。
- 教师提供实验器材和指导,确保学生能够顺利完成实验。
3. 项目展示与评价- 学生展示自己的项目成果,包括系统设计、实现过程和测试结果。
- 教师和学生共同评价项目,总结经验教训。
五、教学案例案例名称:基于Arduino的智能灯光控制系统案例描述:本案例旨在设计一个基于Arduino的智能灯光控制系统,实现对家中灯光的远程控制。
Arduino之红外遥控的制作——基础⼀、红外遥控制作——基础1、作品应⽤⽬的:制作红外遥控器,可代替电视机顶盒的遥控对其进⾏控制。
2、所需设备材料:1)、arduino uno板⼦ x12)、arduino 扩展板 x13)、红外接收模块 x14)、红外发射模块 x15)、电视机顶盒遥控器 x16)、跳线 x23、制作的原理:电视机顶盒遥控利⽤红外发射编码对机顶盒进⾏控制;获取机顶盒遥控的红外发射码,同时利⽤红外发射模块发射相同的红外码就可对机顶盒进⾏控制。
4、获取电视机顶盒遥控红外编码:——————————获取遥控红外发射编码—————————————————#include // 引⽤ IRRemote 函式库const int irReceiverPin = 12; // 红外线接收器 OUTPUT 讯号接在 pin 2IRrecv irrecv(irReceiverPin); // 定义 IRrecv 物件来接收红外线讯号decode_results results; // 解码结果将放在 decode_results 结构的 result 变数⾥void setup(){Serial.begin(9600); // 开启 Serial port, 通讯速率为 9600 bpsirrecv.enableIRIn(); // 启动红外线解码Serial.print("begin:\n");}// 显⽰红外线协定种类void showIRProtocol(decode_results *results){Serial.print("Protocol: ");// 判断红外线协定种类switch(results->decode_type) {case NEC:Serial.print("NEC");break;case SONY:Serial.print("SONY");break;case RC5:Serial.print("RC5");break;case RC6:Serial.print("RC6");break;default:Serial.print("Unknown encoding");}// 把红外线编码印到 Serial portSerial.print(", irCode: ");Serial.print(results->value, HEX); // 红外线编码Serial.print(", bits: ");Serial.println(results->bits); // 红外线编码位元数}void loop(){if (irrecv.decode(&results)) { // 解码成功,收到⼀组红外线讯号showIRProtocol(&results); // 显⽰红外线协定种类irrecv.resume(); // 继续收下⼀组红外线讯号}}———————————————————————————机顶盒遥控上数字1⾄9及0的红外编码如下:Protocol: NEC, irCode: 806F807F, bits: 32 //数字1Protocol: NEC, irCode: 806F40BF, bits: 32 //数字2Protocol: NEC, irCode: 806FC03F, bits: 32 //数字3Protocol: NEC, irCode: 806F20DF, bits: 32 //数字4Protocol: NEC, irCode: 806FA05F, bits: 32 //数字5Protocol: NEC, irCode: 806F609F, bits: 32 //数字6Protocol: NEC, irCode: 806FE01F, bits: 32 //数字7Protocol: NEC, irCode: 806F10EF, bits: 32 //数字8Protocol: NEC, irCode: 806F906F, bits: 32 //数字9Protocol: NEC, irCode: FFFFFFFF, bits: 0 //重复码Protocol: NEC, irCode: 806F00FF, bits: 32 //数字0—————————————————————————————————————利⽤红外发射模块,每五秒钟依次发送数字键0⾄9的红外编码—————#includeIRsend irsend;void ircodeSEND(){irsend.sendNEC(0x806F00FF, 32); // channel 0 红外发射码前需要加上“0x”delay(5000);irsend.sendNEC(0x806F807F, 32); //channel 1delay(5000);irsend.sendNEC(0x806F40BF, 32); //channel 2delay(5000);irsend.sendNEC(0x806FC03F, 32); //channel 3delay(5000);irsend.sendNEC(0x806F20DF, 32); //channel 4delay(5000);irsend.sendNEC(0x806FA05F, 32); //channel 5delay(5000);irsend.sendNEC(0x806F609F, 32); //channel 6delay(5000);irsend.sendNEC(0x806FE01F, 32); //channel 7delay(5000);irsend.sendNEC(0x806F10EF, 32); //channel 8delay(5000);irsend.sendNEC(0x806F906F, 32); //channel 9delay(5000);}void setup(){pinMode(3,OUTPUT);Serial.begin(9600);}void loop(){ircodeSEND();}——————————————————————————下载完程序后,就可接上外接电源,在机顶盒前进⾏测试,控制电视频道啦!5、思考:⽬前的红外遥控控制机顶盒只限于固定的0⾄9红外码的顺序发送,可否进⼀步升级,与arduino其他模块结合对电视机顶盒进⾏多样化的控制呢?此问题,将在下⼀博⽂中进⾏研究;也欢迎⼤家提供更好的控制形式或⽅法,若本⽂有错误之处也请批评指正!谢谢!。
Arduino Uno 硬件电路
Arduino UNO硬件介绍
这一章会对照开发板简单讲解一下硬件原理图,如果你想深入了解硬件原理图,这里附上官网的PDF版。
下图是一张原理图和开发板的概览图:
)
稳压电路
外接电源输入进来的电压可能在5V附近,为了保证更加精
准的5V电压,防止电压过高穿透芯片。
这里选用的是
NCP117ST50T3G 稳压芯片,这款稳压芯片输出电压可调范围是1.5-12V。
稳压电路的连接方式及计算公式可查此链接。
下载电路
这块UNO 板采用Atmega16U2 这款USB 芯片做下载电路,一般需要单独的下载模块下载程序,但此开发板直接将下载电路集成到了开发板上。
这里直接可连USB 线进行下载,像Ardunino mini 这种小系统板是需要单独的下载模块的。
主芯片最小系统
如上图,这里可以独立出 UNO 的最小系统板,我们编程最如上图,这里可以独立出
关心的就是这个最小系统的 GPIO 接口。
晶振的选择几个元关心的就是这个最小系统的
器件的选择可参考 Atmega328 数据手册。
下图是我们经常器件的选择可参考
操作的一些管脚,比如,我们下一章节将要用的的开发板中的13管脚,它对应的是芯片的19管脚,B端口的第五个管而除了作为普通的 IO 管脚外,它的第二功能就是SCK 脚,而除了作为普通的
通信中作为时钟信号。
(同步时钟),SPI通信中作为时钟信号。
Product Reference ManualSKU: A000066DescriptionThe Arduino UNO R3 is the perfect board to get familiar with electronics and coding. This versatile microcontroller is equipped with the well-known ATmega328P and the ATMega 16U2 Processor.This board will give you a great first experience within the world of Arduino.Target areas:Maker, introduction, industriesFeaturesATMega328P ProcessorMemoryAVR CPU at up to 16 MHz32KB Flash2KB SRAM1KB EEPROMSecurityPower On Reset (POR)Brown Out Detection (BOD)Peripherals2x 8-bit Timer/Counter with a dedicated period register and compare channels1x 16-bit Timer/Counter with a dedicated period register, input capture and compare channels1x USART with fractional baud rate generator and start-of-frame detection1x controller/peripheral Serial Peripheral Interface (SPI)1x Dual mode controller/peripheral I2C1x Analog Comparator (AC) with a scalable reference inputWatchdog Timer with separate on-chip oscillatorSix PWM channelsInterrupt and wake-up on pin changeATMega16U2 Processor8-bit AVR® RISC-based microcontrollerMemory16 KB ISP Flash512B EEPROM512B SRAMdebugWIRE interface for on-chip debugging and programmingPower2.7-5.5 volts444445556677777789910101111111212131313CONTENTS1 The Board1.1 Application Examples 1.2 Related Products 2 Ratings2.1 Recommended Operating Conditions 2.2 Power Consumption 3 Functional Overview3.1 Board Topology 3.2 Processor 3.3 Power Tree 4 Board Operation4.1 Getting Started - IDE4.2 Getting Started - Arduino Web Editor 4.3 Getting Started - Arduino IoT Cloud 4.4 Sample Sketches 4.5 Online Resources 5 Connector Pinouts5.1 JANALOG 5.2 JDIGITAL5.3 Mechanical Information5.4 Board Outline & Mounting Holes 6 Certifications6.1 Declaration of Conformity CE DoC (EU)6.2 Declaration of Conformity to EU RoHS & REACH 211 01/19/20216.3 Conflict Minerals Declaration 7 FCC Caution8 Company Information 9 Reference Documentation 10 Revision History1 The Board1.1 Application ExamplesThe UNO board is the flagship product of Arduino. Regardless if you are new to the world of electronics or will use the UNO as a tool for education purposes or industry-related tasks.First entry to electronics: If this is your first project within coding and electronics, get started with our most used and documented board; Arduino UNO. It is equipped with the well-known ATmega328P processor, 14 digital input/output pins, 6 analog inputs, USB connections, ICSP header and reset button. This board includes everything you will need for a great first experience with Arduino.Industry-standard development board: Using the Arduino UNO board in industries, there are a range of companies using the UNO board as the brain for their PLC’s.Education purposes: Although the UNO board has been with us for about ten years, it is still widely used for various education purposes and scientific projects. The board's high standard and top quality performance makes it a great resource to capture real time from sensors and to trigger complex laboratory equipment to mention a few examples.1.2 Related ProductsStarter KitTinkerkit Braccio RobotExample2 Ratings2.1 Recommended Operating ConditionsSymbol Description Min Max Conservative thermal limits for the whole board:-40 °C (-40°F)85 °C ( 185°F) NOTE: In extreme temperatures, EEPROM, voltage regulator, and the crystal oscillator, might notwork as expected due to the extreme temperature conditions2.2 Power ConsumptionSymbol Description Min Typ Max Unit VINMax Maximum input voltage from VIN pad6-20V VUSBMax Maximum input voltage from USB connector- 5.5V PMax Maximum Power Consumption--xx mA 3 Functional Overview3.1 Board TopologyTop viewBoard topologyRef.Description Ref.DescriptionX1Power jack 2.1x5.5mm U1SPX1117M3-L-5 RegulatorX2USB B Connector U3ATMEGA16U2 ModulePC1EEE-1EA470WP 25V SMD Capacitor U5LMV358LIST-A.9 ICPC2EEE-1EA470WP 25V SMD Capacitor F1Chip Capacitor, High DensityD1CGRA4007-G Rectifier ICSP Pin header connector (through hole 6)J-ZU4ATMEGA328P Module ICSP1Pin header connector (through hole 6)Y1ECS-160-20-4X-DU Oscillator3.2 ProcessorThe Main Processor is a ATmega328P running at up tp 20 MHz. Most of its pins are connected to the external headers, however some are reserved for internal communication with the USB Bridge coprocessor.3.3 Power TreePower tree4 Board Operation4.1 Getting Started - IDEIf you want to program your Arduino UNO while offline you need to install the Arduino Desktop IDE [1] To connect the Arduino UNO to your computer, you’ll need a Micro-B USB cable. This also provides power to the board, as indicated by the LED.4.2 Getting Started - Arduino Web EditorAll Arduino boards, including this one, work out-of-the-box on the Arduino Web Editor [2], by just installing a simple plugin.The Arduino Web Editor is hosted online, therefore it will always be up-to-date with the latest features and support for all boards. Follow [3] to start coding on the browser and upload your sketches onto your board.4.3 Getting Started - Arduino IoT CloudAll Arduino IoT enabled products are supported on Arduino IoT Cloud which allows you to Log, graph and analyze sensor data, trigger events, and automate your home or business.4.4 Sample SketchesSample sketches for the Arduino XXX can be found either in the “Examples” menu in the Arduino IDE or in the “Documentation” section of the Arduino Pro website [4]4.5 Online ResourcesNow that you have gone through the basics of what you can do with the board you can explore the endless possibilities it provides by checking exciting projects on ProjectHub [5], the Arduino Library Reference [6] and the online store [7] where you will be able to complement your board with sensors, actuators and more5 Connector PinoutsPinout5.1 JANALOGPin Function Type Description1NC NC Not connected2IOREF IOREF Reference for digital logic V - connected to 5V 3Reset Reset Reset4+3V3Power+3V3 Power Rail5+5V Power+5V Power Rail6GND Power Ground7GND Power Ground8VIN Power Voltage Input9A0Analog/GPIO Analog input 0 /GPIO10A1Analog/GPIO Analog input 1 /GPIO11A2Analog/GPIO Analog input 2 /GPIO12A3Analog/GPIO Analog input 3 /GPIO13A4/SDA Analog input/I2C Analog input 4/I2C Data line14A5/SCL Analog input/I2C Analog input 5/I2C Clock line5.2 JDIGITALPin Function Type Description1D0Digital/GPIO Digital pin 0/GPIO2D1Digital/GPIO Digital pin 1/GPIO3D2Digital/GPIO Digital pin 2/GPIO4D3Digital/GPIO Digital pin 3/GPIO5D4Digital/GPIO Digital pin 4/GPIO6D5Digital/GPIO Digital pin 5/GPIO7D6Digital/GPIO Digital pin 6/GPIO8D7Digital/GPIO Digital pin 7/GPIO9D8Digital/GPIO Digital pin 8/GPIO10D9Digital/GPIO Digital pin 9/GPIO11SS Digital SPI Chip Select12MOSI Digital SPI1 Main Out Secondary In13MISO Digital SPI Main In Secondary Out14SCK Digital SPI serial clock output15GND Power Ground16AREF Digital Analog reference voltage17A4/SD4Digital Analog input 4/I2C Data line (duplicated)18A5/SD5Digital Analog input 5/I2C Clock line (duplicated)5.3 Mechanical Information5.4 Board Outline & Mounting HolesBoard outline6 Certifications6.1 Declaration of Conformity CE DoC (EU)We declare under our sole responsibility that the products above are in conformity with the essential requirements of the following EU Directives and therefore qualify for free movement within markets comprising the European Union (EU) and European Economic Area (EEA).ROHS 2 Directive 2011/65/EUConforms to:EN50581:2012Directive 2014/35/EU. (LVD)Conforms to:EN 60950-1:2006/A11:2009/A1:2010/A12:2011/AC:2011 Directive 2004/40/EC & 2008/46/EC & 2013/35/EU,EMFConforms to:EN 62311:20086.2 Declaration of Conformity to EU RoHS & REACH 211 01/19/2021Arduino boards are in compliance with RoHS 2 Directive 2011/65/EU of the European Parliament and RoHS 3 Directive 2015/863/EU of the Council of 4 June 2015 on the restriction of the use of certain hazardous substances in electrical and electronic equipment.Substance Maximum limit (ppm)Lead (Pb)1000Cadmium (Cd)100Mercury (Hg)1000Hexavalent Chromium (Cr6+)1000Poly Brominated Biphenyls (PBB)1000Poly Brominated Diphenyl ethers (PBDE)1000Bis(2-Ethylhexyl} phthalate (DEHP)1000Benzyl butyl phthalate (BBP)1000Dibutyl phthalate (DBP)1000Diisobutyl phthalate (DIBP)1000Exemptions: No exemptions are claimed.Arduino Boards are fully compliant with the related requirements of European Union Regulation (EC) 1907 /2006 concerning the Registration, Evaluation, Authorization and Restriction of Chemicals (REACH). We declare none of the SVHCs (https://echa.europa.eu/web/guest/candidate-list-table), the Candidate List of Substances of Very High Concern for authorization currently released by ECHA, is present in all products (and also package) in quantities totaling in a concentration equal or above 0.1%. To the best of our knowledge, we also declare that our products do not contain any of the substances listed on the "Authorization List" (Annex XIV of the REACH regulations) and Substances of Very High Concern (SVHC) in any significant amounts as specified by the Annex XVII of Candidate list published by ECHA (European Chemical Agency) 1907 /2006/EC.6.3 Conflict Minerals DeclarationAs a global supplier of electronic and electrical components, Arduino is aware of our obligations with regards to laws and regulations regarding Conflict Minerals, specifically the Dodd-Frank Wall Street Reform and Consumer Protection Act, Section 1502. Arduino does not directly source or process conflict minerals such as Tin, Tantalum, Tungsten, or Gold. Conflict minerals are contained in our products in the form of solder, or as a component in metal alloys. As part of our reasonable due diligence Arduino has contacted component suppliers within our supply chain to verify their continued compliance with the regulations. Based on the information received thus far we declare that our products contain Conflict Minerals sourced from conflict-free areas.7 FCC CautionAny Changes or modifications not expressly approved by the party responsible for compliance could void the user’s authority to operate the equipment.This device complies with part 15 of the FCC Rules. Operation is subject to the following two conditions:(1) This device may not cause harmful interference(2) this device must accept any interference received, including interference that may cause undesired operation. FCC RF Radiation Exposure Statement:1. This Transmitter must not be co-located or operating in conjunction with any other antenna or transmitter.2. This equipment complies with RF radiation exposure limits set forth for an uncontrolled environment.3. This equipment should be installed and operated with minimum distance 20cm between the radiator &your body.English: User manuals for license-exempt radio apparatus shall contain the following or equivalent notice in a conspicuous location in the user manual or alternatively on the device or both. This device complies with Industry Canada license-exempt RSS standard(s). Operation is subject to the following two conditions:(1) this device may not cause interference(2) this device must accept any interference, including interference that may cause undesired operation of the device.French: Le présent appareil est conforme aux CNR d’Industrie Canada applicables aux appareils radio exempts de licence. L’exploitation est autorisée aux deux conditions suivantes :(1) l’ appareil nedoit pas produire de brouillage(2) l’utilisateur de l’appareil doit accepter tout brouillage radioélectrique subi, même si le brouillage est susceptible d’en compromettre le fonctionnement.IC SAR Warning:English This equipment should be installed and operated with minimum distance 20 cm between the radiator and your body.French: Lors de l’ installation et de l’ exploitation de ce dispositif, la distance entre le radiateur et le corps est d ’au moins 20 cm.Important: The operating temperature of the EUT can’t exceed 85℃ and shouldn’t be lower than -40℃. Hereby, Arduino S.r.l. declares that this product is in compliance with essential requirements and other relevant provisions of Directive 2014/53/EU. This product is allowed to be used in all EU member states.8 Company InformationCompany name Arduino S.r.lCompany Address Via Andrea Appiani 25 20900 MONZA Italy9 Reference DocumentationReference LinkArduino IDE(Desktop)https:///en/Main/SoftwareArduino IDE (Cloud)https:///editorCloud IDE Getting Started https:///projecthub/Arduino_Genuino/getting-started-with-arduino-web-editor-4b3e4aArduino Pro Website https:///proProject Hub https:///projecthub?by=part&part_id=11332&sort=trending Library Reference https:///reference/en/Online Store https:///10 Revision HistoryDate Revision Changesxx/06/20211Datasheet release。
米思齐之一-点亮真实的LED知识点:1、认识元器件:Arduino UNO主控板、扩展板、LED灯模块2、认识Mixly程序模块:数字输出、延时、循环3、程序设计:顺序结构任务一、点亮板载LED灯1、程序编写双击Mixly文件夹中Mixly.exe文件,即可打开Mixly软件:目前使用Mixly软件0.9982、根据Arduino UNO3及驱动程序在电脑中的地址,在Mixly软件中选择相应的位置本机Arduino UNO3是COM76(根据各自不同的配置而定)3、点击输入/输出模块跳出对应选项选择数字输出模块,点击左键拖动到空白区管脚0处点击下拉菜单选择13(Arduino UNO3上的板载灯针对13号管脚)同时把13号管脚设为高电平(点亮)点击右下角的上传按键(编译的主要功能是检查程序的正确性)直到左下角对话框中出现上传成功为止,上传期间请勿插拔数据线(出现其他提示,请仔细阅读前几节内容,完成Arduino UNO3主控板的驱动安装)这是你会发现Arduino UNO3主控板和扩展板上有一个标有“L”的LED 灯常亮,说明你的Arduino UNO3主控板和你的电脑已经正常通讯了。
任务二:点亮真实的LED灯所需材料:Arduino UNO3主控板*1、扩展板*1、LED灯模块*1物理连接:*扩展板与主控板根据对应的针脚插好*取出一个LED模块,用连接线将其与10号管脚对应的三个管脚相连(注意插线时颜色的对应:红色基本代表电源正极VCC、黑色基本代表电源负极GND)LED模块硬件接线图延续任务一的程序,把管脚13改为10(因为LED模块连接在10号管脚)接下来增加延时功能,在“控制”菜单中找到“延时模块”,拖动至空白处并与“数字输出”模块拼接(1000毫秒=1秒,1000微妙=1毫秒)(相同的模块命令可以右击鼠标复制)(把数字输出管脚10号设为低),继续增加延时功能编写好程序后,单击“上传”,将程序上传到UNO3主控板上。
Arduino uno的制作与调试 Arduino由一个基于单片机的开放源码的硬件平台和一套专的开发门环境组成。它可以用来开发交互产品,比如它可以读取大量的开关和传感器信号,并且可以控制各式各样的电灯、电机和其他物理设备。 经过两个星期的对三块Arduino uno板子的焊接与调试,我已经大概比较熟练的掌握了贴片元件及一些小芯片的焊接技术。现在我想讲讲Arduino uno rev1 这块板子的制作与调试过程。 一、焊接 由于Arduino uno rev1 的硬件是开源的,所以我们可以直接拿来用。 1. 拿到PCB板(图1)
图1 Arduino uno rev1 PCB 2. 根据元器件清单购置元器件 元器件清单如图2。 图2 元器件清单 3. 焊接元器件 根据图3来焊接元器件。 图3 PCB焊接图 这里我想说说焊接的方法与技巧(供初学者参考)。这块板子中还是有存在一些比较难焊的地方。 1) 芯片ATmega8U2 Arduino UNO与之前Arduino 2009版本的最大不同在于USB转串口部分,Arduino 2009采用的是FTDI专用芯片FT232RL,而Arduino UNO采用的是用一块ATmega8U2模拟出串口的做法。这一改动着实带来了不小的麻烦,第一是该方案所采用的ATmega8U2芯片基本上在市场上很难找到,另外一点就是该芯片的封装加大了焊接的难度和成本。 芯片ATmega8U2的封装很小,而且它芯片的外面没有引脚,可以看到的是它的焊盘非常的小。焊接方法为:在各个焊盘上滴上锡,完了后检查一下有没有焊盘连接在一起的,然后用镊子夹住芯片ATmega8U2,小心的对准位置,对准后用镊子压住芯片,用电烙铁在一边的周围滑动加热,使得焊盘上的锡熔化,则芯片的引脚就焊在了焊盘上,同样的,其他三边也这样。焊完之后用万用表检查一下。 2) 贴片晶振及其他的贴片元器件 因为左手是拿镊子夹住器件对准位置,右手拿电烙铁,所以没有另外的手来添加焊锡。这时就需要先在对应的一个焊盘上滴一点焊锡,再将器件对准位置,用电烙铁在上面加热,焊锡熔化就与元器件连接在一起,在焊接另外一个焊盘。 焊接完成后如图4所示。再用万用表检查各个焊点。 图4 Arduino uno rev1 二、原理图分析 1. 外接电源输入部分 Arduino UNO可以使用外接电源进行输入,A是电源输入口,电源的输入的范围为7V到12V.。图5中B是二极管,二极管的特性是单向导通。使用二极管的目的是:即使电源输入的正反极性反转,也不会烧毁线路板上的元器件。C是稳压管,把输入电压稳定在5V。由于C器件的输入和输出间需要一定的压差,所以A的输入电压不能低于7V。另外,如果A的输入电压过高,会使得器件C输入和输出电压差过大,从而使得C因为温度过高也烧毁。用户在使用外接电源输入时,请把输入电源的电压范围控制在7V到12V之间。原则上,越靠近7V越好。
图5 外接电源输入部分 2. USB电源输入部分 Arduino UNO也可以使用USB口直接供电。图6中A是USB接头,可以给Arduino UNO提供5V的电压。B是保险管,当UNO所需要的电流大于500mA的时候,该保险管会自动断开,以防止损坏电脑。图中C是10K的排阻,用来对上面提到的外接电源输入进行分压。当外接电源输入电压VIN大于7V时,D器件的第3脚由于电压高于D器件的第2脚(3.3V),所以D器件的第1脚输出高电平。器件E是PMOS,当D器件的第1脚输出高电平时,器件E处于截至状态,从而切断了USB接口的供电。当外接电源输入电压VIN小于6V时,D器件的第3脚由于电压低于D器件的第2脚(3.3V),所以D器件的第1脚输出低电平。器件E处于导通状态,此时,Arduino UNO由USB口进行供电。器件F是线性稳压器,负责把5V电源转变成3V电源,该器件能给Arduino UNO提供大约50mA的电流。
图6 USB电源输入部分 3. ATmega8U2/ATmega16U2 ATmega8U2和ATmega16U2是USB接口芯片,其特征包括: 1)8K/16K字节的Flash,支持自擦写功能。512字节EEPROM和512字节SRAM (8U和16U的不同处是Flash容量) 2)内置Boot-Loader功能。 3)支持USB全速,包含4个USB输入输出端口 4)包含内置晶振。 5)操作电压范围为2.7V到5.5V。2.7V时,最大工作频率是8MHz,4.5V时,最大工作频率是16MHz。
三、Arduino uno板子的调试 1. USBtinyISP的驱动安装 Arduino uno的调试用到工具官方支持下载线 USBtinyISP 。USBtinyISP也是一款 为AVR单片机设计的基于USB接口的ISP下载线,使用它可以为大部分AVR单片机下载程序。在Arduino IDE中,USBtinyISP是一直被支持的下载线,用来下载其bootloader,与之前使用的USBasp 下载线相比,使用起来更加简单。 首先下载USBtinyISP驱动程序,将其解压缩到硬盘上备用。将下载线通过USB线连接到计算机后,系统会提示找到相应的硬件:
在随后出现的“找到新的硬件向导”对话框中,选“否,暂时不”,然后单击“下一步”按钮:
在随后出现的对话框中,选“从列表或指定位置安装(高级)”,然后单击“下一步”按钮: 接着指定之前解压缩开的驱动文件所在的目录: 单击“下一步”按钮之后,系统就开始安装USBtinyISP所需要的驱动文件: 最后单击“完成”按钮,就大功告成了:
此时在系统的硬件管理器中,我们能够找到“USBtinyISP AVR Programmer”,表明该下载线已经可以使用了: USBtinyISP在设计的时候,设置了相应的跳线来为单片机供电。在为Arduino下载bootloader的时候,我们需要将该跳线短路,这样就不需要再为Arduino提供额外的电源了:
2. ATMega8U2固件烧写与驱动安装 安裝好USBtinyISP驱动之后,首先要向ATMega8U2内写入相应的USB固件(firmware)。在Arduino-0022安装目录下的hardware\arduino\firmwares目录下,我们可以找到为Arduino UNO 编译好的USB固件文件UNO-dfu_and_usbserial_combined.hex。编译时需要调用avrdude,我们先从arduino 0022中找到avrdude的两个文件,avrdude.exe,avrdude.conf,如下图: 把他们放入arduino-0022\hardware\arduino\firmwares文件夹下面 Arduino UNO上为ATMega8U2单片机也留出了ICSP接口,我们可以借助它来下载相应的USB固件,使用的工具是USBTinyISP。把tinyISP与8U2芯片上方的ICSP接口连接好。ICSP线的街头上,有一个小三角,那个指向的是1号口。板子上ICSP的1号口也都有标记,如图: 然后进入命令状态,进入arduino-0022\hardware\arduino\firmwares目录,输入命令: avrdude -p at90usb82 -F -P usb -c usbtiny -U flash:w:UNO-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m 这段命令后半部分是设置熔丝位,熔丝低位ff,高位d9,扩展位f4,lock位0f。
完成以后我们就可以把uno的usb口连接电脑,测试是否下载成功(如果下载固件失败,很可能是ATmega8U2焊接失败)。 在win7下连接后,会提示找到新硬件 因为系统驱动中没有包含,所以会提示安装失败,不要紧。 这时进入控制面板中的系统
在有感叹号的uno上点右键,选择更新驱动。 然后选择手工查找驱动
选择驱动目录,默认是在arduino-0022\drivers目录下。 提示不用管,安装就可以。 3. ATmega328芯片bootloader的烧写 用6芯的连接线将USBtinyISP和Arduino上的ICSP座连接起来:
注意由于Arduino的ICSP座并没有设计反插反的座,你需要6芯连接线上带三角形的那一位是对应于ICSP座上的“1”: 硬件连接好之后,此时可以打开Arduino的IDE了。在菜单“Tools”->“Board”列表中选择好你的Arduino板子的型号 之后,就可以通过菜单“Tools”->“Burn Bootloader”->“w/ USBtinyISP”来下载Arduino的bootloader:
整个下载的过程中,USBtinyISP上红色的BUSY灯会一直亮着,表明其正在工作: 整个下载过程会持续一段时间,但速度与USBasp相比还是要快一些。下载完成之后,在Arduino IDE窗口中会显示“Done burning bootloader”:
4. 测试 到现在为止,板子已经全部好了,接下来将导入程序进行测试。拔掉USBtinyISP下载器,直接用USB连接板子。