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 775B

12345678910111213141516171819202122232425
  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. output is: 10101010
  6. */
  7. #include "Port_MCP23S17.h"
  8. const uint8_t IOE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins grounded
  9. Port_MCP23S17 portB(IOE_ADDR, 1, ~0); //read all pins
  10. void setup()
  11. {
  12. uint8_t BitPattern; //reading of port B
  13. delay(6000);
  14. portB.begin(HIGH); //HIGH or LOW, does not matter
  15. BitPattern = portB.read();
  16. Keyboard.print("BitPattern = ");
  17. Keyboard.println(BitPattern, BIN); //prints 10101010
  18. }
  19. void loop() { }