Using classes with the Arduino

前端 未结 7 1809
孤独总比滥情好
孤独总比滥情好 2020-12-25 11:01

I\'m trying to use class objects with the Arduino, but I keep running into problems. All I want to do is declare a class and create an object of that class. What would an e

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-25 11:41

    There is an excellent tutorial on how to create a library for the Arduino platform. A library is basically a class, so it should show you how its all done.

    On Arduino you can use classes, but there are a few restrictions:

    • No new and delete keywords
    • No exceptions
    • No libstdc++, hence no standard functions, templates or classes

    You also need to make new files for your classes, you can't just declare them in your main sketch. You also will need to close the Arduino IDE when recompiling a library. That is why I use Eclipse as my Arduino IDE.

提交回复
热议问题