I2C communication is not working I have been working on my project but I get an error and I need some advice or correction.

I use I2C method to communicate between master and slave. I've got two questions:


I send 7 inputs (from master) to the slave but only receives 6
Will my coding make an output like this video


Master Code

// Master Code
#include &lt;Wire.h&gt;
byte nChar =0;
char input[7];

void setup () {

  Serial.begin(9600);
  Wire.begin();
}

void loop()
{
  if (nChar &lt; 7) {if (Serial.available()) { input[nChar++] = Serial.read();}}

    else {

      Wire.beginTransmission(1);

      //a
      Wire.write(input[0]);
      Serial.print("Drawer : ");
      Serial.println(input[0]);

      //x
      Wire.write(input[1]);
      Serial.print("Output : ");
      Serial.println(input[1]);

      //00
      Wire.write(input[2]);
      Wire.write(input[3]);
      Serial.print("Output : ");
      Serial.print(input[2]);
      Serial.println(input[3]);

      //y
      Wire.write(input[4]);
      Serial.print("Output : ");
      Serial.println(input[4]);

      //00
      Wire.write(input[5]);
      Wire.write(input[6]);
      Serial.print("Output : ");
      Serial.print(input[5]);
      Serial.println(input[6]);

      delay(15);

      while (Serial.available())
      {
        //Remove extra
        Serial.read();
      }
      Wire.endTransmission();
        nChar = 0;
    }
  }


Slave Code

#include &lt;Wire.h&gt;
byte ledPins[] = {12, 11, 10, 9, 8, 7, 6};
byte ledPins2[] = {12, 11, 10, 9, 8, 7, 6};
byte count;
byte nChar;
char c;
char input[8];
char data[30] = "";
int n;
#define nBits sizeof(ledPins)/sizeof(ledPins[0])
#define nBits sizeof(ledPins2)/sizeof(ledPins[0])    

void setup()
{
  Wire.begin(1);
  Serial.begin(9600);
  for (byte i = 0; i &lt; nBits; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
for (byte i = 0; i &lt; nBits; i++) {
    pinMode(ledPins2[i], OUTPUT);
    }
  Serial.begin(9600);
}

void loop()
{
  if (nChar &lt; 8) {                    //accumulate three characters
    if (Serial.available()) {
      c = Serial.read();
      input[nChar++] = c;
    }
  }
  else {
    input[8] = 1;                   //atoi() expects string terminator
    n = atoi(input);                //convert the input characters to integer
    dispBinary(n);
    delay(100);                     //wait for any additional characters   
    while (Serial.available()) {    //ignore them
      c = Serial.read();
    }
    nChar = 1;
  }
}    

void receiveEvent(int howMany)
{
  while (1 &lt; Wire.available()) {
    char c = Wire.read();
    Serial.print(c);
  }
}

void dispBinary(int n) //Vertical
{
  if (n &gt;= 0 &amp;&amp; n &lt;= 5) {
    for (byte i = 0; i &lt; nBits; i++) {
      digitalWrite (ledPins[i], n &amp; 1);
      n /= 2;
    }
  }
}

void dispBinary2(int n) //Horizontal
{
  if (n &gt;= 0 &amp;&amp; n &lt;= 5) {
    for (byte i = 0; i &lt; nBits; i++) {
      digitalWrite (ledPins2[i], n &amp; 1);
      n /= 2;
    }
  }

}

void b()
{
  if (data[0] != 'a')
  {
    dispBinary(atoi("00"));
    delay(100);
    dispBinary2(atoi("00"));
    delay(100);
    goto fin;
  }
  if (data[1] = 'x')
  {
    char xdata[2] = {data[2], data[3]};//(data[2], data[3]);
    dispBinary2(atoi(xdata));
    delay(100);
  }
  if (data[4] = 'y')
  {
    char ydata[2] = {data[5], data[6]};//(data[5], data[6]);
    dispBinary(atoi(ydata));
    delay(100);
  }

fin:;
}
Most coders would your while (1 &lt; Wire.available()) { write as while ( Wire.available() &gt; 1) { and read it "repeat while there is more the 1 byte available". but wait, why leave that one byte there? you want "repeat while there is no more byte available".

you need while (0 &lt; Wire.available())