版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Page13-16 Uploading an Arduino Sketch上传一个Arduino SketchTo show you how to upload code to your Arduino board,well show you a simple example.This is one of the most basic examples -it consists in blinking the on-board LED or digital pin 13 every second.为了向你展示如何在你的Arduino板子上上传代码,我们会给你看个简单的例子,这可是最简单的例子之
2、一主要每秒是LED灯闪烁或者数字引脚13次。1.Open your Arduino IDE.1.打开你的Arduino IDE。2.Go to File-Examples-Basics-Blink2.按照步骤 File(文件)-Examples(例子)-01.Basics(基础)-Blink(闪烁)By default,the Arduino IDE comes pre-configured for the Arduino UNO.Click the Upload button and wait a few seconds.默认情况下,Arduino UNO上的Arduino IDE会被预配置
3、。点击Upload(上传)按钮然后等待几秒钟。After a few seconds, you should see a Done uploading message.几秒钟之后,你将会看到一条完成上传的消息。This code simply blinks the on-board LED on your Arduino UNO (highlighted with red color). You should see the little LED turn on for one second, and turn off for another second repeatedly.这段代码会使你
4、的Arduino Uno板上的LED闪烁(用红色突出显示)。你应该会看到小LED打开一秒然后关闭一秒,并重复进行.Control an Output and Read an Input控制输出并读取输入An Arduino board contains digital pins, analog pins and PWM pins.Arduino板包含数字引脚、模拟引脚和PWM引脚。Difference between digital, analog and PWM数字引脚,模拟引脚和PWM引脚的区别In digital pins, you have just two possible stat
5、es, which are on or off. These can also be referred as High or Low, 1 or 0 and 5V or OV. For example, if an LED is on, then, its state is High or1 or 5V. If it is off, youll have low, or 0 or 0V.在数字引脚状态下,你只有两个可能的状态,打开或关闭。这些也可以称为高电平或低电平,1或0,5V或0V。例如,如果一个LED是打开的,那么,它的状态是高电平或1或5V。如果它是关闭的,将会是低电平或0或0V。In
6、 analog pins, you have unlimited possible states between 0 and 1023. This allows you to read sensor values. For example, with a light sensor, if it is very dark, youll read 1023, if it is very bright youll read 0 .If there is a brightness between dark and very bright, youll read a value between 0 an
7、d 1023.在模拟引脚中,在0和1023之间具有无限的可能状态。这允许你读取传感器值。例如,用光传感器,如果光线很暗,你会读取到的值为1023,如果光线很亮,你会读取到的值为0,如果光线介于很亮和很暗之间,你会读取到0到1023之间的值。PWM pins are digital pins, so they output either 0 or 5V. However these pins can output “fake” intermediate voltage values between 0 and 5V, because they can perform Pulse Width Mo
8、dulation (PWM). PWM allows to simulate varying levels of power by oscillating the output voltage of the Arduino.PWM引脚是数字引脚,因此它们输出0或5V。然而,这些引脚可以输出“假的“ 0到5V之间的中间电压值,因为它们可以执行”脉冲宽度调制“(PWM)。PWM允许通过振荡Arduino的输出电压来“模拟”不同的功率水平。Controlling an output输出控制To control a digital output you use the digitalWrite() f
9、unction and between brackets you write, the pin you want to control, and then HIGH or LOW.你使用digitalWrite()函数来控制数字输出,并在括号之间写下要控制的引脚和高低电平。To control a PWM pin you use the analogWrite() function and between brackets you write the pin you want to control and a number between 0 and 255.你使用analogWrite()函
10、数来控制PWM引脚,并在括号之间写入要控制的引脚和0到255之间的数字。Reading an input输入读取To read an analog input you use the function analogRead() and for a digital input you use digitalRead().使用函数analogRead()来读取模拟输入;对于数字输入,请使用函数digitalRead()。The best way for you to learn Arduino is practising. So, choose a project and start buildi
11、ng something.学习Arduino的最佳方法就是练习。 所以,选择一个项目并开始做出一些东西吧。Traffic Lights交通信号灯View code on GitHub请在GitHub上查看代码Click here点击这里查看Introduction介绍In this project youre going to build a traffic lights system:在这个项目中,你将建立一个交通信号灯系统:l There are 3 LEDs with different colors (green, yellow and red) to mimic the traffic lights for the cars.用三种不同颜色的灯(绿色,黄色和红色)模拟汽车的交通信号灯l There are 2 LEDs with different colors (gre
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2027届贵州省黔东南州凯里六中学化学九年级第一学期期中综合测试试题含解析
- 辽宁省抚顺市新宾满族自治县2027届九上物理期末质量跟踪监视试题含解析
- 四川省遂宁市2027届九年级化学第一学期期末达标检测模拟试题含解析
- 2027届黑龙江省齐齐哈尔市拜泉县物理九年级第一学期期末监测模拟试题含解析
- 河南省郑州市第八中学2027届化学九年级第一学期期末质量检测模拟试题含解析
- 2026中国休闲食品行业市场现状渠道变革及投资回报分析研究报告
- 2027届贵州遵义市正安县九年级化学第一学期期中统考试题含解析
- 2026中国HUD投影芯片组光学方案竞争与前装市场渗透障碍分析
- 2027届四川省宜宾市翠屏区二片区九年级物理第一学期期末检测试题含解析
- 2026中国医疗美容仪器市场规范化发展与国际竞争力分析报告
- 2026年数字安徽有限责任公司所属企业安徽数安系统集成有限公司第1批次社会招聘考试参考题库及答案详解
- 2026年中小学教师(语文)副高级职称评审答辩题库及答案
- 学校管理与教师专业发展手册
- 初中音乐七年级上册《美丽的草原我的家》深度鉴赏与跨文化理解教案
- 2026秋新人教版英语五年级上册单元一Unit 1 Different friends测试卷-提高卷附答案(文档中已插入听力音频)
- 2026广西南宁市青秀区伶俐镇人民政府招聘2人(劳务派遣)笔试参考题库及答案详解
- 2026年餐饮服务食品安全管理员试题及答案
- 2024版电网典型设计10kV配电站房分册
- 23J916-1 住宅排气道(一)
- 华润电力招聘测评试题
- 中药热奄包疗法操作评分标准
评论
0/150
提交评论