#define PCA9555\_INTERRUPT\_PIN 2 // PCA9555 interrupt on pin ~D11 (INT0) #define PCA9555\_ADDRESS 0x20 // device address of PCA9555
PCA9555 pca9555 = PCA9555(2); // instance of PCA9555 without interrupt
void setup() { // pin initialization pinMode(PCA9555_INTERRUPT_PIN, INPUT_PULLUP); // pin initialization for PCA9555 interrupt input with internal pull-up resistor enabled attachInterrupt(digitalPinToInterrupt(PCA9555_INTERRUPT_PIN), PCA9555_interruptHandler, FALLING); // enable interrupt handler for PCA9555 interrupt with falling edge trigger
// initialize serial communication #ifdef \_CONSOLE Serial.begin(BAUDRATE); // open serial communications with defined baudrate // loop not required for debug console only while (!Serial) { ; // wait until port is open (only necessary for native USB port) } delay(500); #endif
// initialize the PCA9555 pca9555.begin(PCA9555_ADDRESS, &Wire); // initialization of the PCA9555 for (uint8\_t i = 0; i < 16; i++){ pca9555.pinMode(i, OUTPUT); // configure all pins as output pca9555.digitalWrite(i,LOW); }
#ifdef \_CONSOLE Serial.println("\nStarting application..."); Serial.println("Application successfully started, all tasks are running"); #endif } int pin = 0; void loop() { for(uint8\_t i = 0;i < 16;i++){ pca9555.digitalWrite(i,HIGH); delay(100); } for(uint8\_t i = 0;i < 16;i++){ pca9555.digitalWrite(i,LOW); delay(100); } }