ArduinoShrink: Faster, Better, Smaller Compiled Arduino Code

This library uses a number of tricks to improve and reduce the size of Arduino sketches.

Jeremy Cook
3 years ago

When you need to do a simple task, a dev board like the Arduino Nano or similar is a great solution. However, as thing start to get more complicated, and your code and implemented libraries stretches on, you may find your microcontroller/board of choice just isn't up to the task. Fortunately, there are a number of other more capable devices on the market – even several options in the Nano form factor if needed – but what if you didn’t have to upgrade? What if there was a way to reduce your code size, and make it run faster at the same time.

As outlined in his Nerd Ralph blog post, Ralph Doncaster claims to have done just that with a new library called ArduinoShrink. Doncaster explains that this library uses a more modular approach than normal when compiling your code. Work was also done in AVR assembler to make it more efficient. This code is designed to reduce interrupt latency, which may or may not be a problem for you, but faster is always (almost always?) better in this case, so it'd be hard to go wrong with such a method.

While there is still some work to be done with the digitalWrite function, ArduinoShrink should be compatible with any Arduino sketch. One example of its performance is that the Arduino Blink example sketch normally takes 924 bytes of flash, but only needs 196 bytes with ArdinoShrink. If you need a little extra space, or even if you don’t, it certainly sounds like it's worth a try!

Jeremy Cook
Engineer, maker of random contraptions, love learning about tech. Write for various publications, including Hackster!
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles