keybrd library is an open source library for creating custom-keyboard firmware.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

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