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.

PortMCP23S17_write.ino 1.0KB

12345678910111213141516171819202122232425262728293031323334
  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-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. OR low-voltage LED, with forward voltage less than 2 volts.
  8. */
  9. #include "PortIOE.h"
  10. #include "PortMCP23S17.h"
  11. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
  12. PortIOE portA(0);
  13. PortMCP23S17 portAWrite(portA, 0); //PortAWrite needed for begin()
  14. //const uint8_t GPIOA = 0x12; //LEDs are on port A
  15. void setup()
  16. {
  17. delay(6000);
  18. portAWrite.begin(LOW); //HIGH or LOW, not matter if readPins=0
  19. Keyboard.print("start writing");
  20. }
  21. void loop()
  22. {
  23. portAWrite.write(~0, HIGH); //set all GPIOA pins HIGH
  24. delay(2000);
  25. portAWrite.write(~0, LOW); //set all GPIOA pins LOW
  26. delay(2000);
  27. }