keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

PortMCP23S17_read.ino 825B

1234567891011121314151617181920212223242526272829
  1. /* unit test for PortMCP23S17
  2. Picture of hardware is in unit_tests/PortMCP23S17_read/PortMCP23S17_bb.JPG
  3. The setup is an MCP23S17 I/O expander on a Teensy LC controller.
  4. MCP23S17 port-B pins are alternately grounded and energized.
  5. portBState is a bitwise reading of port B.
  6. output is: 10101010
  7. */
  8. #include "PortIOE.h"
  9. #include "PortMCP23S17.h"
  10. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
  11. PortIOE portB(1);
  12. PortMCP23S17 portBRead(portB, ~0);
  13. void setup()
  14. {
  15. uint8_t portBState; //bit pattern
  16. delay(6000);
  17. portBRead.begin(HIGH); //HIGH or LOW, not matter
  18. portBState = portBRead.read();
  19. Keyboard.print("portBState = ");
  20. Keyboard.println(portBState, BIN); //prints 10101010
  21. }
  22. void loop() { }