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 1020B

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