[Solved] PinMode in Object Constructors/Functions?

Quick question for anyone who happens to know :stuck_out_tongue: : Are pinMode() calls allowed in object constructors? After reading this: http://forum.arduino.cc/index.php?topic=78114.0 it seems the better move it to put it inside of literally any other function other than the constructor so I ask more generally: can I set the pinMode inside of an object?

I can test this myself but I thought I’d ask first. If I don’t get a response in a few hours I’ll whip up a quick question and report back.

Thanks!

We had issues early on when porting Arduino libraries with hardware calls (pinMode, Serial, digitalWrite) in constructors, but we fixed that so you should be ok. That said if I was designing a new library, I would put all of the hardware initialization in the begin() method which would be called in setup().

2 Likes

That’s my current plan. Thanks for validating said plan.