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

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

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

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




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

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

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

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

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


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



后记,小编朋友公司研发了一个游戏化的少儿编程在线课程(5-12岁),游戏化教学结合scratch(一款在线少儿编程工具,类似乐高的积木拼搭),我家娃娃学了几次课,非常喜欢(超预期),16次课才200多块钱,对锻炼孩子的思维能力和动手动力很有帮助。
声明:转载此文是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。