Yield function, printable class and mapping arrays: Useful but unknown features from Arduino core


Yahya Tawil over at Atadiat wrote a new tip for Arduino developers about three hidden and useful features in Arduino core:

Arduino core, the source code of Arduino API functions and classes, has three useful features that can be used effectively. As the Arduino core documentation doesn’t mention them (at least until the time of publishing this micro-blog), these features are not well-known for arduino developers. Let’s discuss each feature of them one by one.

More details at Atadiat blog.

Via the contact form.


Join the Conversation


  1. yield() instead of proper interrupt-driven code? Ewwwwwww… somebody please teach these Arduino folks proper AVR microcontroller programming!

    1. Well, there’s your problem. Or rather, the problem with Arduino in general: a) not using interrupts for anything that can’t wait, and b) using delay() at all, for anything that could wait but never, ever should unless you’re literally writing a single LED blink sketch. “We brake for nobody” should be the One Rule – if you have stuff to do, do it; if you don’t, pass execution to the next thing in line. And if you have ten nested “for” loops, maybe you should return and let everything else do some stuff between each iteration instead of lingering around for half an eternity at a time…

    2. See the source files of Arduino core first before writing comments.

      yield is defined in Arduino core as a weak function and called in the delay function. Just as a simple as that! no one said it’s good for interrupt-driven code.

      And it’s not related to AVR MCU programming. It’s an embedded C topic.

      1. Yes, I know how weak symbols work.

        Yes, I would still prefer interrupt-driven schemes when coding with embedded C.


      2. Yahya, relax. Some of us are just trained differently. Nobody is outright wrong.

        Massimo Banzi appears to be a software guy. He was at Interaction Design Institue Ivrea. IIRC, and started Ard there, likely not a hard engineering school. Artists always wants MCUs to sequence things, not too different from the more art-focused MIT Media Lab projects. He lists ‘Interaction Designer’ first in the second sentence in his About page. Look at his consultancy list, it screams interaction design or HCI, not embedded MCU or hard engineering. His wisdom will help you get things done quickly, but may not be appropriate among say, automotive or aviation electronics.

      3. KY, I just hate how some engineers and experienced people thing about Arduino.

        And by the way I’m computer engineer and I worked in an RnD department.

        As a bare-metal c developer I learned alot from Arduino core and I try to make the reader aware about the source files and details behind Arduino platform. I just want the hobbyists understand the low level of Arduino which is very good to make them capable to move on to AVR programming later. I know exactly that Arduino style wastes the AVR resources while making programming easy. it’s not a win-win thing, but it is a very interested way to introduce abstraction to MCUs.


      4. Max and I, we’re like, just shooting the breeze here. Relax, “hate” is a strong word. The embedded world has been overwhelmed by the Arduino culture, a simplified scheme made by folks who were once involved in the Processing language and was originally targeted towards artist types. Some people like me are always going to poke the Arduino bubble a bit, sorry if it irked you, you should get used to it. :-)

        Arduino is a sort of a champion from the software-centric side. An overwhelming voice from one side is bad if it drowns out other voices. One trend I see is that some software folks (I’m talking in general here) (or maybe the younger set) think they can solve big things, we should get on with them, move at express speed, some traditional hardware folks are just holding progress back. A case in point: Tesla’s confidence in autopilot tech and barrelling ahead with aggressive implementation. Others too, but Tesla’s stuff entails higher risk. One bad glitch every one million hours may still kill plenty of people. Sometimes ideas hit the jackpot, sometimes they don’t (e.g. internet balloons, and such). Don’t mind dinosaurs like me too much, because well, blog on stuff and people will always argue or nitpick, heh.

  2. ^^Amen. I like the ease of use and hardware-agnosticism that the Arduino has. Perfect for quick prototyping and slapping together quick. Instant gratification. But if I ever want to do something ‘serious’ I’ll turn to a PIC with C. Something even more serious like time-dependent code for software-PWM – I’ll go to assembly. Do I code in assembly everyday? Nope – too difficult and takes too long to make anything complicated.

Leave a comment

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

Notify me of followup comments via e-mail. You can also subscribe without commenting.