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.

PortMCP23018_write.ino 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. /* unit test for Port_MCP23018
  2. Picture of hardware is in unit_tests/PortMCP23018_read/PortMCP23018_bb.JPG todo
  3. The setup is an MCP23018 I/O expander on a Teensy LC controller.
  4. MCP23018 port-A GPIO pins are not connected to anything.
  5. Port-A GPIO-pin ouputs alternate between 0 and 3.3 volts.
  6. volt meter between pin A1 and power because
  7. MCP23018 has open-drain outputs (open-drain can only sink current)
  8. Use a volt meter to measure port-A GPIO-pin outputs or red LED.
  9. */
  10. #include "Port_MCP23018.h"
  11. const uint8_t IOE_ADDR = 0x20; //MCP23018 address ADDR pin grounded
  12. Port_MCP23018 portA(IOE_ADDR, 0, 0);
  13. void setup()
  14. {
  15. delay(6000);
  16. Keyboard.println("PortMCP23018_write.ino");
  17. portA.beginProtocol();
  18. portA.begin(LOW); //HIGH or LOW, not matter if readPins=0
  19. }
  20. void loop()
  21. {
  22. portA.write(~0, HIGH); //set all GPIOA pins HIGH
  23. Keyboard.print("+");
  24. delay(2000);
  25. portA.write(~0, LOW); //set all GPIOA pins LOW
  26. Keyboard.print("0");
  27. delay(2000);
  28. }