GY-63_MS5611/libraries/MCP23S17/examples/MCP23S17_digitalWrite/MCP23S17_digitalWrite.ino

75 lines
1.4 KiB
Arduino
Raw Normal View History

2022-01-07 14:23:20 -05:00
//
// FILE: MCP23S17_digitalWrite.ino
// AUTHOR: Rob Tillaart
2023-08-14 06:56:15 -04:00
// PURPOSE: test MCP23S17 library
// URL: https://github.com/RobTillaart/MCP23S17
2022-01-07 14:23:20 -05:00
#include "MCP23S17.h"
#include "SPI.h"
2023-08-14 06:56:15 -04:00
MCP23S17 MCP(10, 5, 6, 7); // SW SPI address 0x00
2022-01-07 14:23:20 -05:00
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.print("MCP23S17_test version: ");
Serial.println(MCP23S17_LIB_VERSION);
delay(100);
SPI.begin();
bool b = MCP.begin();
2022-04-14 04:53:15 -04:00
Serial.println(b ? "true" : "false");
2022-01-07 14:23:20 -05:00
delay(100);
2023-08-14 06:56:15 -04:00
MCP.pinMode8(0, 0x00); // 0 = output , 1 = input
2022-01-07 14:23:20 -05:00
MCP.pinMode8(1, 0x00);
Serial.println("TEST digitalWrite(0)");
delay(100);
for (int i = 0; i < 16; i++)
{
2023-08-14 06:56:15 -04:00
MCP.digitalWrite(0, i % 2); // alternating HIGH/LOW
2022-01-07 14:23:20 -05:00
Serial.print(i % 2);
Serial.print(' ');
delay(100);
}
Serial.println();
Serial.println();
Serial.println("TEST digitalWrite(pin)");
delay(100);
for (int pin = 0; pin < 16; pin++)
{
2023-08-14 06:56:15 -04:00
MCP.digitalWrite(pin, 1 - pin % 2); // alternating HIGH/LOW
2022-01-07 14:23:20 -05:00
Serial.print(1 - pin % 2);
Serial.print(' ');
delay(100);
}
Serial.println();
Serial.println();
Serial.println("TEST read back");
for (int pin = 0; pin < 16; pin++)
{
int val = MCP.digitalRead(pin);
Serial.print(val);
Serial.print(' ');
delay(100);
}
Serial.println();
Serial.println();
}
void loop()
{
}
2023-08-14 06:56:15 -04:00
// -- END OF FILE --
2022-01-07 14:23:20 -05:00