Arduino软件开发环境搭建

简 介: 给出了Arduino开发软件的下载与测试过程。

关键词 ArduinonIDE

 

§01 Arduino软件下载安装


1、下载链接

  下载的连接

  1. Arduino官方网站 ,其中包括 Windows 7下载版本

  2. Arduino中文社区下载页面 ,提供了 腾讯微云下载量连接

  3. CSDN 网站上下载链接: CSDN网站下载链接: 1.8.15 Windows &

  从Auduino官方网站下载到Arduino-1.8.15安装程序。程序保存在:

D:\Disk\Develop\Arduino\arduino-1.8.15-windows.exe

2、安装Arduino IDE

  点击运行Arduino-1.8.15-Windows.exe ,安装缺省配置安装软件。

▲ Arduino安装过程

▲ Arduino安装过程

  在安装的后半程,软件提示是否相安装Arduino USB Driver。同意安装USB driver 软件。

▲ 安装Arduino USB Driver

▲ 安装Arduino USB Driver

  安装驱动器软件需要联网下载,这个过程需要等待的时间比较长。

▲ Arduino安装完毕

▲ Arduino安装完毕

3、首次运行Arduino IDE

  在第一次运行Arduino的过程中,会出现Windows的防火墙提示,缺省情况下允许访问。

▲ 允许Windows防火墙对于程序的部分功能的阻止

▲ 允许Windows防火墙对于程序的部分功能的阻止

  下面是第一次运行Arduino出现的IDE的界面。

▲ Arduino IDE 开发环境

▲ Arduino IDE 开发环境

4、建议将界面修改成英文

为了能够与更多的网络资料所叙述的保持一致,建议将Arduino IDE的界面文字修改成英文。可以参考: Arduino IDE显示语言修改 中修改的方式。

▲ 将Arduino的界面修改成英文

▲ 将Arduino的界面修改成英文

 

§02 接Arduino硬件


  边有几款Arduino的硬件版,下面逐一来连接一下测试相应的功能。

1、Grove Beginner Kit

  这款硬件版是通过CP2101N USB接口芯片与Windows连接的。

▲ Grove Beginer Kits

▲ Grove Beginer Kits

  使用 MicroUSB 线缆将Arduino连入Windows,在Windows设备管理下的端口中出现 Silicon Labs CP210x USB to UART Bridge(COM7)

▲ 连接之后Windows下的虚拟串口

▲ 连接之后Windows下的虚拟串口

(1)设置开发环境

  通过工具菜单栏设置IDE与开发板之间的通讯串口,以及开发板的型号。

工具配置:
端口:COM7
开发板
开发板:Arduino_Uno

▲ 设置端口与开发板信息

▲ 设置端口与开发板信息

(2)测试程序

  下面的程序是从“文件”菜单中的“示例程序”中自动生成的“Blink without Delay”。 修改其中的:

const long interval=1000

  可以修改闪烁LED的频率。单位: ms。

  下面是完整的程序。

/*
  Blink without Delay

  Turns on and off a light emitting diode (LED) connected to a digital pin,
  without using the delay() function. This means that other code can run at the
  same time without being interrupted by the LED code.

  The circuit:
  - Use the onboard LED.
  - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
    and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
    is set to the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your
    Arduino model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
  modified 11 Nov 2013
  by Scott Fitzgerald
  modified 9 Jan 2017
  by Arturo Guadalupi

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 200;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

  通过“项目”中的**显示项目文件夹(CTRL+K)**可以获得上面测试程序对应的电路原理图以及UNO电路板连接图。

▲ 测试程序对应的配置

▲ 测试程序对应的配置

(3)编译下载运行

  通过项目菜单中的上传(CTRL+U)功能将程序编译上载运行。或者直接点击IDE左上角的 运行“右箭头”按钮。

▲ 运行按钮

▲ 运行按钮

  说实在的,相比于其它的编译器,Arduino的编译过程显得有点慢,时间长了。

▲ 编译下载运行

▲ 编译下载运行

  下载程序之后,程序便可开始运行了。

▲ 板上的LED闪烁

▲ 板上的LED闪烁

2、UNO开发板

(1)将开发板接入Windows

  UNO 开发板使用的CH340G作为USB与Windows接口,

▲ UNO 开发板

▲ UNO 开发板

  使用USB电缆将UNO开发板接入PC,此时在Windows中出现了 USB-SERIALCH340(COM31)串口。

▲ 接入系统之后出现的CH340虚拟串口

▲ 接入系统之后出现的CH340虚拟串口

(2)修改Arduino设置

  将Arduino的设置中的端口修改为 COM31,重新下载执行程序。程序执行支撑,
▲ 下载测试程序之后UNO运行情况

▲ 下载测试程序之后UNO运行情况

3、MEGA2560

(1)将电路板接入Windows

  MEGA2560电路板使用MEGA16U作为USB的接口芯片。使用USB线将MEGA2560电路板接入Windows之后,电脑的计算机管理中的设备管理中出现Arduino Mega 2560(COM41) 虚拟串口。

▲ Arduino MEGA

▲ Arduino MEGA

▲ 电脑出现Arduino Mega 2560(COM41) 虚拟串口

▲ 电脑出现Arduino Mega 2560(COM41) 虚拟串口

(2)修改设置

  通过Arduino中的工具中的端口以及开发板选项进行正确的设置。

Arduino工具设置:
开发板:Arduino_Mega_or_Mega_2560
处理器:ATMega2560
端口:COM41(Arduino_Mega)

▲ 对Arduino的开发环境进行设置

▲ 对Arduino的开发环境进行设置

  按动Ctrl+U将程序重新下载执行。

▲ 下载程序后运行情况

▲ 下载程序后运行情况

 

建过程总结 ※


  文给出了对于基于Arduino开发环境的IDE的下载安装过程的叙述。并对于手边的三种Arduino的电路板分别进行了测试。

 


  ■ 相关文献链接:

 

§* 软件附件


1、修改后的crunpython.py

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# CRUNPYTHON.PY                -- by Dr. ZhuoQing 2020-01-23
#
# Note:
#============================================================

from head import *
from tsmodule.tsstm32       import *

altflag = 0
keyread = tspread()
if keyread[9] != 0: altflag = 1

#------------------------------------------------------------
ret = tspsendwindowkey('Arduino', "a", control=1)
if ret == 0:
    tspcopyclipboard()
    tspsendwindowkey("Arduino", 'vu', control=1)
    printf('\a')
    exit()

#------------------------------------------------------------
ret = tspsendwindowkey('Project - IAR Embedded Workbench IDE', 'pm', alt=1)

if ret != 0:
    ret = tspsendwindowkey('ImageCraft', 'pm', alt=1)

if ret != 0:
    stm32cmd("CLOSEPORT")
    tspsendwindowkey('¦ÌVision', 'pb', alt=1)

    if altflag == 0: tspfocuswindow("TEASOFT:1")

    time.sleep(3.0)

    if altflag == 0:
        stm32cmd("REOPENPORT")
    else:
        stm32cmd("REOPENPORTFOCUS")
        tspfocuswindow("STM32")

#------------------------------------------------------------
#        END OF FILE : CRUNPYTHON.PY
#============================================================

2、执行arduino命令

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# ARD.PY                       -- by Dr. ZhuoQing 2021-05-24
#
# Note:
#============================================================

from head import *

arduino_title = "Arduino"

#------------------------------------------------------------

if len(sys.argv) == 1:
    tspsendwindowkey(arduino_title, "acv", control=1)
    tsppasteclipboard()
    printf('\a')
    exit()

#------------------------------------------------------------

if sys.argv[1] == '>':
    tspcopyclipboard()
    tspsendwindowkey(arduino_title, "avu", control=1)
    printf('\a')
    exit()

#------------------------------------------------------------
tspsendwindowkey(arduino_title, "u", control=1)
printf('\a')

#------------------------------------------------------------
#        END OF FILE : ARD.PY
#============================================================
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卓晴

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值