GY-63_MS5611/libraries/PCF8574/examples/PCF8574_test/PCF8574_test.ino

71 lines
1014 B
Arduino
Raw Normal View History

2013-09-30 12:23:20 -04:00
//
// FILE: PCF8574_test.ino
// AUTHOR: Rob Tillaart
// DATE: 7-febr-2013
// PUPROSE: test PCF8574 library
2021-12-23 06:51:26 -05:00
2013-09-30 12:23:20 -04:00
#include "PCF8574.h"
PCF8574 PCF_01(0x38);
2021-12-23 06:51:26 -05:00
2013-09-30 12:23:20 -04:00
void setup()
{
2021-01-29 06:31:58 -05:00
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("PCF8574_LIB_VERSION:\t");
2013-09-30 12:23:20 -04:00
Serial.println(PCF8574_LIB_VERSION);
2021-01-29 06:31:58 -05:00
PCF_01.begin();
2013-09-30 12:23:20 -04:00
int x = PCF_01.read8();
Serial.print("Read ");
Serial.println(x, HEX);
delay(1000);
}
2021-12-23 06:51:26 -05:00
2013-09-30 12:23:20 -04:00
void loop()
{
Serial.println("HLT");
while (Serial.available() == 0);
2021-01-29 06:31:58 -05:00
switch (Serial.read())
2013-09-30 12:23:20 -04:00
{
case 'H': doHigh(); break;
case 'L': doLow(); break;
case 'T': doToggle(); break;
}
}
2021-12-23 06:51:26 -05:00
2013-09-30 12:23:20 -04:00
void doHigh()
{
PCF_01.write(4, HIGH);
int x = PCF_01.read8();
Serial.print("Read ");
Serial.println(x, HEX);
}
2021-12-23 06:51:26 -05:00
2013-09-30 12:23:20 -04:00
void doLow()
{
PCF_01.write(4, LOW);
int x = PCF_01.read8();
Serial.print("Read ");
Serial.println(x, HEX);
}
2021-12-23 06:51:26 -05:00
2013-09-30 12:23:20 -04:00
void doToggle()
{
PCF_01.toggle(4);
int x = PCF_01.read8();
Serial.print("Read ");
Serial.println(x, HEX);
}
2021-12-23 06:51:26 -05:00
// -- END OF FILE --