Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/unit_tests/PortMCP23S17_write/PortMCP23S17_write.ino

35 lines
1.0 KiB
Arduino
Raw Normal View History

/* unit test for PortMCP23S17
Picture of hardware is in unit_tests/PortMCP23S17_read/PortMCP23S17_bb.JPG
2016-09-01 02:29:59 +00:00
The setup is an MCP23S17 I/O expander on a Teensy LC controller.
MCP23S17 port-A GPIO pins are not connected to anything.
Port-A GPIO-pin ouputs alternate between 0 and 3.3 volts.
Use a volt meter to measure port-A GPIO-pin outputs.
OR low-voltage LED, with forward voltage less than 2 volts.
2016-09-01 02:29:59 +00:00
*/
#include "PortIOE.h"
#include "PortMCP23S17.h"
2016-09-01 02:29:59 +00:00
2016-09-03 20:25:22 +00:00
const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
PortIOE portA(0);
2016-09-01 02:29:59 +00:00
PortMCP23S17 portAWrite(portA, 0); //PortAWrite needed for begin()
2016-09-01 02:29:59 +00:00
//const uint8_t GPIOA = 0x12; //LEDs are on port A
2016-09-01 02:29:59 +00:00
void setup()
{
delay(6000);
portAWrite.begin(LOW); //HIGH or LOW, not matter if readPins=0
Keyboard.print("start writing");
2016-09-01 02:29:59 +00:00
}
void loop()
{
portAWrite.write(~0, HIGH); //set all GPIOA pins HIGH
delay(2000);
portAWrite.write(~0, LOW); //set all GPIOA pins LOW
delay(2000);
}