keybrd library is an open source library for creating custom-keyboard firmware.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

PortRead_MCP23S17.ino 1009B

1234567891011121314151617181920212223242526272829303132
  1. /* unit test for PortRead_MCP23S17
  2. The setup is an MCP23S17 I/O expander on a Teensy LC controller.
  3. MCP23S17 port-B pins are alternately grounded and energized.
  4. portBState is a bitwise reading of port B.
  5. output is: 10101010
  6. posted on http://arduino.stackexchange.com/questions/tagged/spi
  7. http://arduino.stackexchange.com/questions/28792/reading-an-mcp23s17-i-o-expander-port-with-the-arduino-spi-library
  8. */
  9. #include "PortIOE.h"
  10. #include "PortRead_MCP23S17.h"
  11. #include "PortWrite_MCP23S17.h"
  12. const uint8_t PortIOE::ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
  13. PortIOE portB(1, 0);
  14. PortRead_MCP23S17 portBRead(portB);
  15. PortWrite_MCP23S17 portBWrite(portB); //PortBWrite needed for begin()
  16. void setup()
  17. {
  18. uint8_t portBState; //bit wise
  19. delay(6000);
  20. portBWrite.begin();
  21. portBState = portBRead.read();
  22. Keyboard.print("portBState = ");
  23. Keyboard.println(portBState, BIN); //should print 10101010
  24. }
  25. void loop() { }