Pinmode2

This supersedes the `pinmode` pull request earlier, as it didn't make it in before things got out of sync.  So this replaces that.