【小白福利】如何入门Arduino(下)
2019-11-20 14:31
【点击上方「蓝字」关注我们,一起成为技术颜控!】
这篇我们再来看看软件部分,然后试着点亮我们的Arduino板子!
Arduino编译环境下载 https://www.arduino.cc/en/Main/Software
(最新版的ArduinoIDE Pro也已经发布,想尝鲜的小伙伴们也可以下载~https://blog.arduino.cc/2019/10/18/arduino-pro-ide-alpha-preview-with-advanced-features/)

这边我们还是以不带Pro版的为例子,根据电脑系统选择合适版本进行安装

提示安装组件,默认next就行

选择安装的路径,可以自行修改,我这边是在虚拟机里面安装的,就默认这个路径了,否则不建议放在系统盘c盘。
静静等待安装ing……


接下来会提示安装驱动和串行端口等信息,直接安装。

新版安装完成语言默认和电脑设定的语言一致,就是中文。
如果你打开的是英文界面,不太习惯的话,也可以更改为中文界面。
打开Arduino主程序,打开:File > Preferences,找到Editor language项,将其设为中文,关闭Arduino主程序并重新打开

会跳出下面这个对话框,选择Editor language --> 简体中文,点击OK。

关闭Arduino IDE,重新打开,就是中文界面了~
认识Arduino
IDE这次小实验目的就是在Arduino
UNO板上点亮13号引脚的LED灯,持续一秒,然后灭掉,再持续一秒,一直循环。
现在,我们假设使用的是Arduino UNO型号的控制板(初学者建议用UNO,稳定),而且按照上面步骤也已经部署好了Arduino开发环境,安装好USB驱动。- 连接Arduino控制板和电脑将USB线一端插在Arduino控制板上,一端插在电脑的USB接口上。(注意:独立工作时Arduino控制板既可以选择从USB供电, 也可以选择用充电宝或电源适配器供电)
连接Arduino控制板和电脑
打开Arudino IDE,就会出现Arduino IDE的编辑界面
-
认识Arduino IDE我们先简单认识一下Arduino的这个编译器,以后可是要经常和它打交道的。

Arduino IDE是Arduino产品的软件编辑环境。简单的说就是用来写代码、下载代码的地方。
任何的Arduino产品都需要下载代码后才能运作。
我们所搭建的硬件电路是辅助代码来完成的,两者是缺一不可的。如同人通过大脑来控制肢体活动是一个道理。如果代码就是大脑的话,外围硬件就是肢体,肢体的活动取决于大脑,所以硬件实现取决于代码。
Arduino IDE基本的功能区已经在上面标示出来了(偷个懒用的旧图,不过和新版的布局一样的),上图大部分的白色区域就是代码的编辑区,用来输入代码的。注意,输入代码时,要切换到英文输入法的模式。下面黑色的区域是消息提示区,会显示编译或者下载是否通过。
- 下载一个Blink程序
下载一个最简单的代码,既可以帮我们熟悉如何下载程序,同时也测试下板子好坏。
UNO板上标有L的LED。这段测试代码就是让这个LED灯闪烁。- 打开Blink插上USB线,打开Arduino IDE后,找到“Blink”代码。
文件 > 示例 > 01.Basics > Blink

-
校验程序通常,写完一段代码后,我们都需要校验一下,看看代码有没有错误。点击“校验”。

校验(编译)完成后,可以看到相应的提示。
由于是样例代码,所以校验不会有错误,不过在以后写代码的过程中,输入完代码,都需要校验一下,然后再下载到Arduino中。
程序在下载之前,我们还要先告诉Arduino IDE,我们用的是什么板子以及相应的串口是哪个。
- 设置板卡型号Arduino包括多种版本的主控器,其中比较常见的是Uno、Leonardo以及Mega系列的控制器(最全选型指南)。
在板子一栏,你需要根据自己选择的主控硬件的固件类型来选择板卡。(样例中选用的以Uno为bootloader的控制器) 工具 > 板卡 > Arduino Uno
-
设置串口工具 > 串口 > xx,这里的xx要和我们电脑设备管理器中看到的一致。
-
下载程序如图,最后,点击“上传”。(这边上传和前面的下载其实是一个意思)

上传完毕!
不出意外,我们就能在板子上直观地看到程序运行的效果了:
Adruino Uno板上13号引脚的LED灯在闪烁。
好了,IDE最最基本的操作就是这些了。
你可能会问,我不怎么会写代码,那要怎么在板子上连接传感器,让传感器实现各种功能呢?
这个时候,可以推荐你先学习MIND+,因为它是图形化编程软件,支持arduino、micro:bit、掌控板等各种开源硬件,只需要拖动图形化程序块即可完成编程,当然它也可以使用python/c/c++等高级编程语言,让大家轻松体验创造的乐趣。通过简单的手动拉取,你就可以实现在IDE里面一样的功能,同时,你也可以看到代码的书写情况,对于初学者非常友好。

正文共:2169字 24图
预计阅读时间:6分钟
(为方便阅读,已标注重点)
上篇文章介绍了什么是Arduino和怎么选Arduino的板子。【小白福利】如何入门Arduino(上)这篇我们再来看看软件部分,然后试着点亮我们的Arduino板子!
Arduino编译环境下载 https://www.arduino.cc/en/Main/Software
(最新版的ArduinoIDE Pro也已经发布,想尝鲜的小伙伴们也可以下载~https://blog.arduino.cc/2019/10/18/arduino-pro-ide-alpha-preview-with-advanced-features/)

这边我们还是以不带Pro版的为例子,根据电脑系统选择合适版本进行安装

提示安装组件,默认next就行

选择安装的路径,可以自行修改,我这边是在虚拟机里面安装的,就默认这个路径了,否则不建议放在系统盘c盘。




接下来会提示安装驱动和串行端口等信息,直接安装。

新版安装完成语言默认和电脑设定的语言一致,就是中文。
如果你打开的是英文界面,不太习惯的话,也可以更改为中文界面。
打开Arduino主程序,打开:File > Preferences,找到Editor language项,将其设为中文,关闭Arduino主程序并重新打开

会跳出下面这个对话框,选择Editor language --> 简体中文,点击OK。

关闭Arduino IDE,重新打开,就是中文界面了~

现在,我们假设使用的是Arduino UNO型号的控制板(初学者建议用UNO,稳定),而且按照上面步骤也已经部署好了Arduino开发环境,安装好USB驱动。- 连接Arduino控制板和电脑将USB线一端插在Arduino控制板上,一端插在电脑的USB接口上。(注意:独立工作时Arduino控制板既可以选择从USB供电, 也可以选择用充电宝或电源适配器供电)
连接Arduino控制板和电脑
打开Arudino IDE,就会出现Arduino IDE的编辑界面


Arduino IDE是Arduino产品的软件编辑环境。简单的说就是用来写代码、下载代码的地方。
任何的Arduino产品都需要下载代码后才能运作。
我们所搭建的硬件电路是辅助代码来完成的,两者是缺一不可的。如同人通过大脑来控制肢体活动是一个道理。如果代码就是大脑的话,外围硬件就是肢体,肢体的活动取决于大脑,所以硬件实现取决于代码。
Arduino IDE基本的功能区已经在上面标示出来了(偷个懒用的旧图,不过和新版的布局一样的),上图大部分的白色区域就是代码的编辑区,用来输入代码的。注意,输入代码时,要切换到英文输入法的模式。下面黑色的区域是消息提示区,会显示编译或者下载是否通过。
- 下载一个Blink程序

下载一个最简单的代码,既可以帮我们熟悉如何下载程序,同时也测试下板子好坏。
UNO板上标有L的LED。这段测试代码就是让这个LED灯闪烁。- 打开Blink插上USB线,打开Arduino IDE后,找到“Blink”代码。
文件 > 示例 > 01.Basics > Blink




由于是样例代码,所以校验不会有错误,不过在以后写代码的过程中,输入完代码,都需要校验一下,然后再下载到Arduino中。
程序在下载之前,我们还要先告诉Arduino IDE,我们用的是什么板子以及相应的串口是哪个。
- 设置板卡型号Arduino包括多种版本的主控器,其中比较常见的是Uno、Leonardo以及Mega系列的控制器(最全选型指南)。
在板子一栏,你需要根据自己选择的主控硬件的固件类型来选择板卡。(样例中选用的以Uno为bootloader的控制器) 工具 > 板卡 > Arduino Uno



上传完毕!
不出意外,我们就能在板子上直观地看到程序运行的效果了:
Adruino Uno板上13号引脚的LED灯在闪烁。
好了,IDE最最基本的操作就是这些了。
你可能会问,我不怎么会写代码,那要怎么在板子上连接传感器,让传感器实现各种功能呢?
这个时候,可以推荐你先学习MIND+,因为它是图形化编程软件,支持arduino、micro:bit、掌控板等各种开源硬件,只需要拖动图形化程序块即可完成编程,当然它也可以使用python/c/c++等高级编程语言,让大家轻松体验创造的乐趣。通过简单的手动拉取,你就可以实现在IDE里面一样的功能,同时,你也可以看到代码的书写情况,对于初学者非常友好。


--end--
声明:本文章由网友投稿作为教育分享用途,如有侵权原作者可通过邮件及时和我们联系删除:freemanzk@qq.com