keybrd library is an open source library for creating custom-keyboard firmware.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
このリポジトリはアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュや、課題・プルリクエストのオープンはできません。

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() { }