如何用C ++编程Arduino [英] How to program an Arduino with C++
问题描述
所以最近我一直在玩我的Arduino,我想知道是否有某种方法可以用C ++编程Arduino.我一直在Vim中使用C ++/处理语言对其进行编程,并使用一个makefile进行编译并上传到Arduino.
So lately I've been playing around with my Arduino and I was wondering if there was some way I could program the Arduino in C++. I've been programming it using the C++/Processing language in Vim and using a makefile to compile and upload to the Arduino.
但是我的目标是能够使用类和所有出色的C ++功能(或至少总和)来对其进行编程.最终,我什至希望在原始C语言中对其进行编程,而我在寻找方法上都遇到了麻烦.如果有人可以向我指出正确的方向或帮助我,那就太好了.
But my goal is to be able to use classes and all the great C++ features (or at least sum) to program it. Eventually I would even love to program it in raw C and I'm just having troubles finding out how to do either. It would be great if someone could point me in the right direction or help me out.
推荐答案
以下是我的经验:我正在使用Arduino,传感器,电机,LED和蓝牙为自闭症儿童构建机器人智能玩具.我编写了自己的库,以完全使用C ++进行所需的工作.但是我发现Arduino IDE编译器是一个较旧的版本,不支持新的C ++ 11功能.
Here is my experience: I'm building a robotic smart toy for autistic children using Arduino, sensors, motors, led and bluetooth. I wrote my own libraries to do exactly what I needed using C++. But I found out that the Arduino IDE Compiler is an older version that does not support the new C++11 features.
所以我不得不找到一种方法来编译C ++ 11代码并将其上传到我的Arduino.事实证明这是漂亮"的基础:我需要一个Makefile,avr-gcc 4.8工具链和voilà! Makefile作业由Sudar( https://github.com/sudar/Arduino-Makefile ),效果很好.我不得不对其进行一些自定义,以使其适用于我的项目.
So I had to find myself a way to compile C++11 code and upload it to my Arduino. It turns out to be "pretty" basic: I needed a Makefile, the avr-gcc 4.8 toolchain and voilà! The makefile job is done by Sudar (https://github.com/sudar/Arduino-Makefile) and it works great. I had to customise it a bit to make it work for my project though.
这是我为项目编写的一些文档.您应该看一下,这可能对您有用. https://github.com/WeAreLeka/moti/blob/master/INSTALL.md
Here is some documentation I've written for my project. You should take a look, it might be useful for you. https://github.com/WeAreLeka/moti/blob/master/INSTALL.md
希望有帮助! 欢呼声:)
Hope it helps! Cheers :)
编辑2014年8月16日:
因为我收到朋友和其他开发人员的与此类似的请求,所以我决定建立某种 framework 来快速轻松地启动并运行您的Arduino项目.
Because I got a lot a requests similar to this one from friends and other devs, I decided to set up some kind of framework to get up and running with your Arduino projects quickly and easily.
希望对您有帮助!如果您发现我可以做得更好的bug或东西,请随时填写和发布. :)
Hope it could be of any help! If you find bugs or stuff that I could make better, feel free to fill and issue. :)
这篇关于如何用C ++编程Arduino的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!