# GPIO on P6

**URL:** <https://forums.openmv.io/t/gpio-on-p6/1094>\
**Category:** OpenMV Boards\
**Created:** [January 18, 2019, 7:35pm UTC](https://forums.openmv.io/t/gpio-on-p6/1094 "2019-01-18T19:35:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwiley](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwiley/32/42_2.png) [@kwiley](https://forums.openmv.io/u/kwiley)\
**Post date:** [January 18, 2019, 7:35pm UTC](https://forums.openmv.io/t/gpio-on-p6/1094/1 "2019-01-18T19:35:04Z")

</div>

P6 is the DAC/ADC line, in addition to a timer. But doesn’t it have to be configured for DAC/ADC first? If I just assign it as a GPIO, shouldn’t it act like a GPIO? I ask because that’s not what I observe. If I set it to a pull-down, it remains up, but if I set it to a pull-up, I can pull it down with a switch. So it doesn’t “respond correctly” to a switch, the way, say, P4 and P5 do, which both respond to a switch correctly in both pull-up or pull-down fashion.

I just hooked a momentary switch between pins 4, 5, or 6 and the 3.3V rail for a pull-down/switch-up test and the ground rail for a pull-up/switch-down test…which I presume was the proper arrangement.

Is there any overarching electronic philosophy as to whether it is better to configure switches in a pull-up/switch-down fashion or the other way around?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [January 18, 2019, 8:41pm UTC](https://forums.openmv.io/t/gpio-on-p6/1094/2 "2019-01-18T20:41:34Z")

</div>

Hi, it should act as a GPIO with pull ups and downs. That could be a bug. Please create a bug on GitHub about this and Ibrahim will take a look and fix it.

As for using pull ups or downs. For switches there’s no particular way you have to go. Most folks do pull ups with a switch pulling to ground however.

---

<div class="post-metadata">

**Author:** ![kwiley](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwiley/32/42_2.png) [@kwiley](https://forums.openmv.io/u/kwiley)\
**Post date:** [January 19, 2019, 12:49am UTC](https://forums.openmv.io/t/gpio-on-p6/1094/3 "2019-01-19T00:49:22Z")

</div>

It could also be this Chinese knock off board I’m working with. I already pointed out that the darn LED is soldered on wrong. 😃

---

<div class="post-metadata">

**Author:** ![kwiley](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwiley/32/42_2.png) [@kwiley](https://forums.openmv.io/u/kwiley)\
**Post date:** [January 19, 2019, 4:25pm UTC](https://forums.openmv.io/t/gpio-on-p6/1094/4 "2019-01-19T16:25:49Z")

</div>

I’m quite certain that what’s going on is I’m doubling up on the LCD’s backlight control by accident. I realize there is some discussion elsewhere about disabling the backlight control pin to provide an additional GPIO, but even without doing that, the pin can still be used as a switch, but only in the pull-up/switch-down fashion. Wired that way, you can detect when the button is down (but of course the LCD briefly goes dark while you press the button). This is sufficient for a momentary switch for providing instantaneous binary signals to the program (for example, to increment a counter or trigger some other single function call and behavior).

So, I have three functional switches at lines P4, P5, and P6. In theory, I would have four if I count P9, but I’m using that for SPI-select to a second SPI device. I’ve found a Qwiic-interfaced I2C keypad on Sparkfun ([SparkFun Qwiic Keypad - 12 Button - COM-15290 - SparkFun Electronics](https://www.sparkfun.com/products/14836)). If I can get that to work, then I can use 12 buttons through just two wires. Presumably I don’t _have_ to use some sort of Qwiic environment for that keypad. I should be able to use the keypad directly (realizing that all Qwiic does is simplify the GPIO-to-I2C layer that I have no particular interest in hacking up through, say, [SparkFun 16 Output I/O Expander Breakout - SX1509 - BOB-13601 - SparkFun Electronics](https://www.sparkfun.com/products/13601), as recommended in another thread). So that will be the next thing I try.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [January 19, 2019, 5:06pm UTC](https://forums.openmv.io/t/gpio-on-p6/1094/5 "2019-01-19T17:06:38Z")

</div>

I2C I/O expansion is the way to go. It just is the easiest way to add a ton of stuff.

---

<div class="post-metadata">

**Author:** ![kwiley](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwiley/32/42_2.png) [@kwiley](https://forums.openmv.io/u/kwiley)\
**Post date:** [January 19, 2019, 5:10pm UTC](https://forums.openmv.io/t/gpio-on-p6/1094/6 "2019-01-19T17:10:56Z")

</div>

Yes, but I’m lazy! 😃

---

<div class="post-metadata">

**Author:** ![iabdalkader](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/iabdalkader/32/1169_2.png) [@iabdalkader](https://forums.openmv.io/u/iabdalkader)\
**Post date:** [January 20, 2019, 2:29am UTC](https://forums.openmv.io/t/gpio-on-p6/1094/7 "2019-01-20T02:29:04Z")

</div>

There was something different about this pin in the datasheet, let me check and get back to you.

EDIT: No actually other than something about current injection, it looks normal. If you’re still having a problem post the code and I’ll test it.
