Communication between arduino uno and ATtiny with a PCF858575

Hi,
Firstly, sorry if it's not the right category, just tell me and I will move it ^^'.

So my question is, I have an Arduino UNO and I connect it to a PCF8575 that I connect to an ATtiny.
The problem is that I don't know how to do the communication between my ATtiny and my Arduino UNO…
What I want is that every time I click on the button, the neopixel turn on and depending on the signal sent by the Arduino UNO, my pixel will light blue or red.

The code of the Arduino UNO (master)

#include <Wire.h>

#define adress1 0x20

void setup() {
  Wire.begin(adress1);
  Wire.onReceive(handler);
}

void loop() {
  Write(B00000000, adress1);
}


void Write(byte _data, uint8_t adress) {
  Wire.beginTransmission(adress);
  Wire.write(_data);
  Wire.endTransmission();
}

void handler(int howMany) {
    byte message = Wire.read();
}

The code of the ATtiny (slave) :

#include <SoftwareSerial.h>
//#include <Adafruit_NeoPixel.h>

#define PIN 0

#define NUMPIXELS 2

//Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

SoftwareSerial master(2,1);

int r, g, b;
int buttonState;

void setup() {
//  pixels.begin();
  master.begin(9600);
  pinMode(2, INPUT);
}

void loop() {
//  for (int i=0; i < NUMPIXELS; i++) {
//    pixels.setPixelColor(i, pixels.Color(r, g, b));
//    pixels.show();
//  }
  buttonState = digitalRead(4);
  master.println(buttonState);
}

Sorry your schematic is fuzzy and the pin numbers and descriptions are not readable. I am also curious as to the 4 wire leds, what are they and can you post a link to them.

NeoPixel (IN OUT VSS VDD)... some Adafruit code in the "ATtiny" are commented-out.

Here 2 links about the neopixel :

Yea I know, I try to just receive the click on the button on my Arduino UNO in the first place then I will try to light the LEDs…

I am just curious why the pcf858575 inbetween.

If I had to design it, I would do something like this.
I would use one wire between the Attiny and the Arduino. Or in fact 3 wires as VCC and GND are also needed.
Arduino listens on that wire if the Attiny sends a pulse, indicating that the button has been pressed.
When pulse sent, Arduino responds after x milliseconds with a High or a Low level on that wire by setting the pin from input to output and apply the level. In the meantime the Attiny has switched the pin from Output to input and is reading after x+1 milliseconds what level the pin is. That will define the neopixel color to set.
After that Attiny switches back to output mode and Arduino to listen mode.

If you do a 1K Ohm resistor somewhere in that wire you will have protection from an error situation where both pins are in output mode, while one pin is High and the other is Low

Yea my circuit doesn't really need the PCF or even the ATtiny, I just simplify my circuit here but in reality I will have 8 PCF. Each PCF will have 8 ATtiny. And each ATtiny will have 2 modules that consist of 1 sensor (here it's a button, but it will be a sensor, it's just not available in Tinkercad ^^') and 1 neopixel band.
So my Arduino will have 8×8×2 = 128 modules…
And the fact that I don't know when I will receive a signal from my sensor/button, so putting the pin in OUTPUT while I could receive a signal…
Plus I can't communicate, like u said, where I send an HIGH or LOW level for my color because I have 4 colors in reality

Mod edit
Quote of spam removed.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.