keybrd library is an open source library for creating custom-keyboard firmware.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

PortRead_MCP23S17.ino 825B

123456789101112131415161718192021222324252627282930
  1. /* unit test for PortRead_MCP23S17
  2. Picture of hardware is in unit_tests/PortRead_MCP23S17/PortRead_MCP23S17_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 "PortRead_MCP23S17.h"
  10. #include "Scanner_IOE.h"
  11. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
  12. PortIOE portB(1, 0);
  13. PortRead_MCP23S17 portBRead(portB, ~0);
  14. void setup()
  15. {
  16. uint8_t portBState; //bit pattern
  17. delay(6000);
  18. portBRead.begin(LOW);
  19. portBState = portBRead.read();
  20. Keyboard.print("portBState = ");
  21. Keyboard.println(portBState, BIN); //prints 10101010
  22. }
  23. void loop() { }