WRITING ARDUINO LIBRARIES, AN EXPERT VIEW

The Arduino IDE has a bit of a split personality. On the one hand, it is a simple environment where you can just pick and choose a few libraries, write a few lines of code, and make lots of interesting things. On the other hand, it is also an ecosystem in which many different boards and libraries can be supported. Writing a great library that everyone can easily use takes a little forethought. There is an official style guide, but a recent post by [Nate] from Sparkfun points out lessons learned from writing more libraries than most people.

Of course, as you might expect, some of this is a matter of opinion, and [Nate] admits that. For example, they always use the serial port at 115,200 baud, but they do note that 9,600 baud is also popular. They also suggest making code as readable as possible, which is usually good advice. In the old days, writing terse code might lead to higher efficiency, but with modern compilers, you ought to get a tight final result even when doing things in a pretty verbose fashion.

However, a lot of the advice is very subtle but important. For example, the use of default parameters and the order of parameters. If you add their advice to the official style guide, you should be well on your way to creating really great Arduino libraries.

Of course, you also need a great idea for a library or an improved library that doesn’t already exist. That may be your most difficult task. Sometimes it makes sense to port something over instead of starting from scratch.

Source: WRITING ARDUINO LIBRARIES, AN EXPERT VIEW


About The Author

Muhammad Bilal

I am a highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top