2021-01-29 06:31:58 -05:00
|
|
|
//
|
|
|
|
// FILE: PCF8575_Wire2.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// DATE: 2021-01-03
|
2021-12-23 07:53:35 -05:00
|
|
|
// PUPROSE: demo
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
#include "PCF8575.h"
|
|
|
|
|
|
|
|
// adjust addresses if needed
|
|
|
|
PCF8575 PCF(0x39, &Wire2);
|
|
|
|
|
2021-12-23 07:53:35 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
Serial.print("PCF8575_LIB_VERSION:\t");
|
|
|
|
Serial.println(PCF8575_LIB_VERSION);
|
|
|
|
|
|
|
|
if (!PCF.begin())
|
|
|
|
{
|
|
|
|
Serial.println("could not initialize...");
|
|
|
|
}
|
|
|
|
if (!PCF.isConnected())
|
|
|
|
{
|
|
|
|
Serial.println("=> not connected");
|
|
|
|
while(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int x = PCF.read16();
|
|
|
|
Serial.print("Read ");
|
|
|
|
Serial.println(x, HEX);
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
2021-12-23 07:53:35 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
Serial.println("HLT");
|
|
|
|
while (Serial.available() == 0);
|
|
|
|
switch (Serial.read())
|
|
|
|
{
|
|
|
|
case 'H': doHigh(); break;
|
|
|
|
case 'L': doLow(); break;
|
|
|
|
case 'T': doToggle(); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 07:53:35 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void doHigh()
|
|
|
|
{
|
|
|
|
PCF.write(4, HIGH);
|
|
|
|
int x = PCF.read16();
|
|
|
|
Serial.print("Read ");
|
|
|
|
Serial.println(x, HEX);
|
|
|
|
}
|
|
|
|
|
2021-12-23 07:53:35 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void doLow()
|
|
|
|
{
|
|
|
|
PCF.write(4, LOW);
|
|
|
|
int x = PCF.read16();
|
|
|
|
Serial.print("Read ");
|
|
|
|
Serial.println(x, HEX);
|
|
|
|
}
|
|
|
|
|
2021-12-23 07:53:35 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void doToggle()
|
|
|
|
{
|
|
|
|
PCF.toggle(4);
|
|
|
|
int x = PCF.read16();
|
|
|
|
Serial.print("Read ");
|
|
|
|
Serial.println(x, HEX);
|
|
|
|
}
|
|
|
|
|
2021-12-23 07:53:35 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-23 07:53:35 -05:00
|
|
|
|