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.

PortWrite_MCP23S17.ino 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* unit test for PortWrite_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-A GPIO pins are not connected to anything.
  5. Port-A GPIO-pin ouputs alternate between 0 and 3.3 volts.
  6. Use a volt meter to measure port-A GPIO-pin outputs.
  7. MCP23S17 on 3.3v does not output enough power to reliable light LEDs
  8. LED lights w/o resistor
  9. LED not light with 56 ohm resistor
  10. */
  11. #include "PortIOE.h"
  12. #include "PortWrite_MCP23S17.h"
  13. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
  14. PortIOE portA(0, 0);
  15. PortWrite_MCP23S17 portAWrite(portA); //PortAWrite needed for begin()
  16. //const uint8_t GPIOA = 0x12; //LEDs are on port A
  17. void setup()
  18. {
  19. delay(6000);
  20. portAWrite.begin();
  21. //Keyboard.print("start blinking");
  22. }
  23. void loop()
  24. {
  25. portAWrite.write(~0, HIGH); //set all GPIOA pins HIGH
  26. delay(2000);
  27. portAWrite.write(~0, LOW); //set all GPIOA pins LOW
  28. delay(2000);
  29. }