user862: I am using a mcp23017 to read button presses for my joystick project and am using the internal pullup to minimize complications. Is there a way to invert all the bits in the uint16_t so i can send the values as normally off?
I'm using this Adafruit library.
And the reading code: uint16_t buttons = mcp.readGPIOAB();

user368: The inversion operator in C++ is ~.
Serial.print(buttons, BIN);
Serial.print(~buttons, BIN);


862: <p>I am using a mcp23017 to read button presses for my joystick project and am using the internal pullup to minimize complications. Is there a way to invert all the bits in the uint16_t so i can send the values as normally off?</p>

<p>I'm using <a href="https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library" rel="nofollow">this Adafruit library</a>.</p>

<p>And the reading code: <code>uint16_t buttons = mcp.readGPIOAB();</code></p>
 368: <p>The inversion operator in C++ is <code>~</code>.</p>

<pre><code>Serial.print(buttons, BIN);
Serial.print(~buttons, BIN);
</code></pre>
