Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "PCF8574.h"
- PCF8574 pcf8574(0x20);
- byte pinWDT = P7;
- byte pinLED = P4;
- byte pinRel[] = {P0, P1, P2, P3};
- bool stateWDT = 0;
- byte dry[] = {35, 34, 39, 36};
- unsigned cur_time_wdt, old_time_wdt;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(115200);
- Serial.println("init pcf: ");
- for (int i = 0; i < sizeof(pinRel); i++) {
- Serial.print(pinRel[i]);
- pinMode(pinRel[i], OUTPUT);
- }
- pcf8574.pinMode(pinWDT, OUTPUT);
- pcf8574.pinMode(pinLED, OUTPUT);
- if (pcf8574.begin()) {
- Serial.println("OK");
- } else {
- Serial.println("KO");
- }
- delay(100);
- for (int i = 0; i < sizeof(pinRel); i++) {
- pcf8574.digitalWrite(pinRel[i], HIGH); // SET RELAY OFF
- }
- }
- void loop() {
- // put your main code here, to run repeatedly:
- cur_time_wdt = millis();
- if (cur_time_wdt - old_time_wdt >= 500) {
- seed_wdt();
- for (int i = 0; i < sizeof(dry); i++) {
- Serial.print(digitalRead(dry[i]));
- Serial.print(",");
- }
- Serial.println();
- old_time_wdt = millis();
- }
- }
- void seed_wdt() {
- stateWDT = !stateWDT;
- pcf8574.digitalWrite(P7, stateWDT);
- pcf8574.digitalWrite(P4, stateWDT);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement