//
//    FILE: pcf8575_test2.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: demo rotateLeft, -Right and toggleMask
//     URL: https://github.com/RobTillaart/PCF8575

// addresses: 0x20 = 000
//            0x27 = 111 

// 27/5/24: One PCF module working with 16 LEDs. Address are all low at 0x20.

// 29/5/24: module working, address changed to 111 0x27.

// can write to a single output - as per PCF and PCF 1 below.

// tested successfully - can control single outputs on individual expanders

#include "PCF8575.h"

//  adjust addresses if needed
//PCF8575 PCF(0x21);  //  add LEDs to lines      (used as output)
PCF8575 PCF(0x20);  // address 0/0/0
// RP: does adding PCF8575 PCF1(0x22); give access to extra expander modules? 22/5/24
PCF8575 PCF1(0x27); // 1/1/1/

void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("PCF8575_LIB_VERSION:\t");
//  Serial.println(PCF8575_LIB_VERSION);

  Wire.begin();

 PCF.begin(); // RP
  PCF1.begin(); // RP
  
    // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  
  

  

  

  //  0010 0111  -> 0x27
  //  1110 0100
 

  
}


void loop()
{
  //write(uint8_t 0, uint8_t 0); //writes a single pin; pin = 0..15; value is HIGH(1) or LOW (0).
  PCF1.write(0,0); //writes a single pin; pin = 0..15; value is HIGH(1) or LOW (0).
  PCF1.write(1,0);
  PCF1.write(15,0);
   delay (1000);
PCF1.write(2,0); //writes a single pin; pin = 0..15; value is HIGH(1) or LOW (0).
PCF1.write(0,1); //writes a single pin; pin = 0..15; value is HIGH(1) or LOW (0).
  PCF1.write(3,0);
  PCF1.write(14,0);
   delay (1000);

  PCF1.write(1,0);
  PCF1.write(15,0);
   delay (1000);
PCF.write(13,0);
delay (1000);
PCF.write(13,1);

  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}


//  -- END OF FILE --
pcf8575Breakout
pcf8575Breakout