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

1234567891011121314151617181920212223242526272829
  1. /* unit test for Port_MCP23S17
  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 or red LED.
  7. */
  8. #include "Port_MCP23S17.h"
  9. const uint8_t IOE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins grounded
  10. Port_MCP23S17 portA(IOE_ADDR , 0, 0); //PortAWrite needed for begin()
  11. void setup()
  12. {
  13. delay(6000);
  14. Keyboard.println("start setup");
  15. portA.begin(LOW); //HIGH or LOW, not matter if readPins=0
  16. Keyboard.println("start loop");
  17. }
  18. void loop()
  19. {
  20. portA.write(~0, HIGH); //set all GPIOA pins HIGH
  21. delay(2000);
  22. portA.write(~0, LOW); //set all GPIOA pins LOW
  23. delay(2000);
  24. }