Closed petervanderwalt closed 6 years ago
Hi, thanks for your reporting. I try various test but with this sketch works correctly
`#include "Arduino.h"
// For arduino uno only pin 1 and 2 are interrupted
// Function interrupt void keyChangedOnPCF8574();
// Set i2c address PCF8574 pcf8574(0x39, ARDUINO_UNO_INTERRUPTED_PIN, keyChangedOnPCF8574); unsigned long timeElapsed; void setup() { Serial.begin(115200);
pcf8574.pinMode(P6, OUTPUT);
pcf8574.pinMode(P0, INPUT);
pcf8574.pinMode(P1, INPUT);
pcf8574.begin();
Serial.println("START");
timeElapsed = millis();
}
bool keyChanged = false; void loop() { if (keyChanged){ Serial.println("P6 OFF"); pcf8574.digitalWrite(P6, LOW); // turn off the LED on P6
// PCF8574::DigitalInput di = pcf8574.digitalReadAll();
Serial.println("READ VALUE FROM PCF: ");
Serial.print(pcf8574.digitalRead(P0));
Serial.print(" - ");
Serial.println(pcf8574.digitalRead(P1));
keyChanged= false;
delay(1000);
Serial.println("P6 ON");
pcf8574.digitalWrite(P6, HIGH); // turn on the LED on P6
}
}
void keyChangedOnPCF8574(){ // Interrupt called (No Serial no read no wire in this function, and DEBUG disabled on PCF library) keyChanged = true; } `
But I think you can't see the change of led status if you don't add a delay.
Can you give me some additional information?
Based off the example sketch: (redacted)
This works
The only difference is me trying to show a status LED on keyPressed
(Redacted version, in my real application i want to turn LED on at other times too.
Problem is, once the digitalWrite happened, the interrupt never fires again