Tinker API Question

The Tinker API has RESTful methods for read/write for digital/analog. My concern is setting the pin prior to actually reading and writing (sending voltage to a component that might not handle it so well). I am guessing that all pins default to a no-voltage output state so this question my be moot. So the initial call to read/write sets the mode for the pin?

Thoughts?

@closir - great question. I wasn’t actually sure how the GPIO pins on the Core are initialized with Tinker, so I loaded the app and checked with a multimeter. What I found is that pins D0 - D7 startup at 0V (1-5mV), and A0 - A7 are floating. So, you’re right, none of the pins default to a voltage output state.

Hope that helps!

1 Like

Thanks for doing the leg work. I am guessing then that each call to read/write/analog/digital also includes an extra call to set or check the pin mode. Simple but not efficient but safe.

Thanks.

Chris

@cloris that’s correct, and if you’re curious to see the code:

https://github.com/spark/core-firmware/blob/master/src/application.cpp

Wow. Thanks. I am working on a WCF based library for calling into Tinker from .Net… this helps. I did notice one thing… is it good to loop like that in the main thread? Would it be more beneficial to utilize a sleep function or such so that the CPU can potentially yield/sleep?

Also, thanks for the Github link… I need to get more familiar with that.

Chris