极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 26206|回复: 10

小白的学习笔记1——用eclipseArduinoIDE写程序

[复制链接]
发表于 2014-10-12 17:55:34 | 显示全部楼层 |阅读模式
本帖最后由 ourutopia 于 2014-10-12 17:57 编辑

话说俺刚接触Arduino,很白很白,这帖子只是把学习过程记录下来,都是很弱的东西,高手们不要鄙视俺,要是能帮到和俺一样白的,那也是善莫大焉了。
——————————————————————————————————————————————————————————
小白写程序都是用eclipse的,所以学习Arduino时自然就想用eclipse,因为俺懒,这样省事。网上找了些帖子看看,感觉开发环境都比较麻烦,这样不符合俺这种懒人的风格,所以我弄了个简单点的。

第一步:下载各种东西
1、JDK,这个去oracle官网下就好了(其实百度下载更快)http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-windows-x64.exe。
2、eclipseArduinoIDE,http://eclipse.baeyens.it/download.php
3、arduino-1.5.6-r2http://www.arduino.cc/en/Main/OldSoftwareReleases,eclipseArduinoIDE要这个版本,现在最新是1.58了,我没试好不好用。     

第二步:安装配置
1、装完eclipseArduinoIDE,打开菜单Window>References设置Arduino项,Arduino IDE path指向arduino-1.5.6-r2安装目录,Arduino Librarie path指向arduino-1.5.6-r2的libraries 目录 ,Arduino hardware path指向arduino-1.5.6-r2的hardware 目录 。

做完这个设置保存是系统会提醒你去http://eclipse.baeyens.it/installAdvice.shtml看配置文档。

2、实际上配置文档里最主要的是要运行下下面的脚本。
@ECHO OFF

:: Recommended usage and things that can go wrong ...
::
:: This batch file does not tollerate spaces or any other strange characters in the path names.
::
:: Recommended usage scenario would be to copy the [arduino_IDE_install_directory]/hardware/arduino directory
::   to a temporary directory that you created at the root of a drive ... something like C:\_temp will do but feel
::   free to call it what ever you want as long as there are no spaces or special characters in it. This ensures
::   there will not be any spaces in any of the path names and also keeps the original files until you are sure
::   the 1200+ files that will be changed are 'right' before you overwrite the originals.
::
:: Now that you have C:\_temp\arduino, put this file in the directory. Make sure the extension is .bat as it may have
::   been changed to something else to allow it to pass thru spam and virus scanning software.
::
:: Run the batch file. It will take a while as it is modifying 1200+ files. If you want to see exactly what it is
::   doing comment out the '@ECHO OFF' ... ':: @ECHO OFF' ... before you execute the batch file.
::
:: After running the batch file and ensuring you are satisfied with the results replace the contents of the
::   [arduino_IDE_install_directory]/hardware/arduino directory with the contents of the C:\_temp\arduino directory.
  ::
:: This batch file does not provide any safeguards related to you doing the wrong thing ... i.e. running it a second time
::   on previously patched files, etc. ... so Stop, Pause, Think is your best course of action.
::

SET temporaryFile=%CD%\temporary_%RANDOM%.txt
SET appendFile=%CD%\textToAppend_%RANDOM%.txt
SET prependFile=%CD%\textToPrepend_%RANDOM%.txt

ECHO #endif>%appendFile%

SET architecture=AVR
ECHO #ifdef ARDUINO_ARCH_%architecture%>%prependFile%
ECHO #endif /* ARDUINO_ARCH_%architecture% */>%appendFile%

PUSHD %architecture%
FOR /F "usebackq delims=*" %%i IN (`dir /b /s *.cpp /s *.h /s *.c`) DO TYPE %prependFile%>%temporaryFile% & TYPE %%i>>%temporaryFile% & TYPE %appendFile%>>%temporaryFile% & MOVE /Y %temporaryFile% %%i
POPD

SET architecture=SAM
ECHO #ifdef ARDUINO_ARCH_%architecture%>%prependFile%
ECHO #endif /* ARDUINO_ARCH_%architecture% */>%appendFile%

PUSHD %architecture%
FOR /F "usebackq delims=*" %%i IN (`dir /b /s *.cpp /s *.h /s *.c`) DO TYPE %prependFile%>%temporaryFile% & TYPE %%i>>%temporaryFile% & TYPE %appendFile%>>%temporaryFile% & MOVE /Y %temporaryFile% %%i
POPD

DEL /F /Q %appendFile%
DEL /F /Q %prependFile%

把上面的代码复制下来,存成.bat文件,然后放到\arduino-1.5.6-r2\libraries目录下运行一下就ok了。

3、在菜单Window>References的C/C++项下面的File Types里面新建两项:*.ino 和*.pde,不建这两项的话没法编译。

第三步:新建项目
File-->new-->new Arduino sketch:
Boards.txt file选项里有avr和sam的两种,我用的nano,所以选avr的。

其他的选项根据自己的情况选就行。然后“下一步”,Finish完事。

接下来就想干嘛干嘛吧~很简单是不~~~




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2014-10-12 23:53:17 | 显示全部楼层
全是英文的吗?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-10-13 23:43:15 | 显示全部楼层
Albert,_Einste 发表于 2014-10-12 23:53
全是英文的吗?

嗯呐,这东西很少有中文的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-11-13 22:43:27 | 显示全部楼层
发现个问题,运行配置脚本时会修改库文件,可能导致库文件不能使用,我用Servo库的时候发现这个问题。

这段脚本会在库文件首尾加上下面的代码
#ifdef ARDUINO_ARCH_SAM
#ifdef ARDUINO_ARCH_AVR
#endif /* ARDUINO_ARCH_AVR */
#endif /* ARDUINO_ARCH_SAM */

解决办法是把arduino ide中自带的库文件覆盖过来就行了。
回复 支持 反对

使用道具 举报

发表于 2014-11-16 21:02:41 | 显示全部楼层
EclipseArduinoIDE可以直接对Arduino板下载程序吗?
回复 支持 反对

使用道具 举报

发表于 2014-11-16 21:03:21 | 显示全部楼层
楼主能否发一个EclipseArduinoIDE的使用教程?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-11-16 21:17:05 | 显示全部楼层
四叔第一 发表于 2014-11-16 21:02
EclipseArduinoIDE可以直接对Arduino板下载程序吗?

可以的,eclipse里面会多一排按钮

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2014-11-17 09:35:08 | 显示全部楼层
ourutopia 发表于 2014-11-16 21:17
可以的,eclipse里面会多一排按钮

还有一个问题EclipseArduinoIDE可以使用ArduinoIDE的库函数吗?
回复 支持 反对

使用道具 举报

发表于 2014-11-17 11:42:17 | 显示全部楼层
赞一个。看起来不错。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-11-17 13:15:26 | 显示全部楼层
四叔第一 发表于 2014-11-17 09:35
还有一个问题EclipseArduinoIDE可以使用ArduinoIDE的库函数吗?

可以啊,不过要注意我后来回的那个帖子,库文件会被配置时的脚本修改掉,那个脚本修改下应该没问题,我懒的动,就不弄了。
回复 支持 反对

使用道具 举报

发表于 2015-4-27 12:53:52 | 显示全部楼层
你好,我刚刚按照您的文章配置了,但是编译的是出错了,请问要怎么解决呢,谢谢啦。。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-17 09:56 , Processed in 0.110391 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表