Arduino Uno slave does not seem to be receiving anything from Uno master

Hello, everyone!

I'm very new to Arduino, and I've been making a project where music was played on a piezo speaker, and its volume was set by another Arduino Uno.

I've been playing around with the Wire library in my project lately, and the slave reads and returns the result in char format: "0". It has come to my understanding that it had read nothing, although the master was sending "volume" (not to be confused with "Volume") in char format (it was NEVER declared as 0) to device 1, which was the address of the slave. Both A4s and A5s are connected as needed. Can someone please tell me where it all went wrong and include the modified code? Thanks!

Take a look:

Master:

#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buttonPin = 10;     
int buttonState;         
String pr = "Pianissimo";
String ps = "pp";
int volume = 1;

void setup() {
  Wire.begin();
  analogReference(DEFAULT);
  delay(10);    
  lcd.begin(16, 2);
  lcd.print("Pianissimo"); 
  lcd.setCursor(0,1);
  lcd.print("pp");
  pinMode(buttonPin, INPUT_PULLUP);
  buttonState = digitalRead(buttonPin);
  pinMode(A0, OUTPUT);
  digitalWrite(A0, HIGH);
  delay(10); 
}



void loop() {
  Wire.beginTransmission(1);
  if (digitalRead(buttonPin) == LOW) {
    volume++;
    if (volume > 6) {
      volume = 1; 
    }
    while (digitalRead(buttonPin) == LOW) {
      delayMicroseconds(1);
    }
  }
  if (volume == 6) {
    if (pr != "Fortissimo") { 
      pr = "Fortissimo";
      ps = "ff";
      Wire.print(char(volume));
      lcd.clear();
      lcd.begin(16, 2);
      lcd.print(pr);
      lcd.setCursor(0,1);
      lcd.print(ps);
    }
  }  
  if (volume == 5) {
    if (pr != "Forte") { 
      pr = "Forte";
      ps = "f";
      Wire.write(char(volume));
      lcd.clear();
      lcd.begin(16, 2);
      lcd.print(pr);
      lcd.setCursor(0,1);
      lcd.print(ps);
    }
  }  
  if (volume == 4) {
    if (pr != "Mezzo forte") { 
      pr = "Mezzo forte";
      ps = "mf";
      Wire.write(char(volume));
      lcd.clear();
      lcd.begin(16, 2);
      lcd.print(pr);
      lcd.setCursor(0,1);
      lcd.print(ps);
    }
  }  
  if (volume == 3) {
    if (pr != "Mezzo piano") { 
      pr = "Mezzo piano";
      ps = "mp";
      Wire.write(char(volume));
      lcd.clear();
      lcd.begin(16, 2);
      lcd.print(pr);
      lcd.setCursor(0,1);
      lcd.print(ps);
    }
  }  
  if (volume == 2) {
    if (pr != "Piano") { 
      pr = "Piano";
      ps = "p";
      Wire.write(char(volume));
      lcd.clear();
      lcd.begin(16, 2);
      lcd.print(pr);
      lcd.setCursor(0,1);
      lcd.print(ps);
    }
  }
  if (volume == 1) {
    if (pr != "Pianissimo") { 
      pr = "Pianissimo";
      ps = "pp";
      Wire.write(char(volume));
      lcd.clear();
      lcd.begin(16, 2);
      lcd.print(pr);
      lcd.setCursor(0,1);
      lcd.print(ps);
    }
  }
  Wire.endTransmission();
}

Slave:

#include <toneAC.h>
#include <Wire.h>

#include "pitches.h"
int melody[] = {
  NOTE_D3, R, NOTE_C3, NOTE_D3, NOTE_D3, R, NOTE_D3, R, NOTE_C3, NOTE_D3, NOTE_D3, R, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_G3, //First row
  NOTE_D3, R, NOTE_C3, NOTE_D3, NOTE_D3, R, NOTE_F3, NOTE_D3, NOTE_E3, NOTE_C3, NOTE_D3, R, NOTE_C3, NOTE_D3, NOTE_D3, R, //Second row 
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 2, 4, 4, 4, 2, 4, 2, 4, 4, 4, 2, 2, 2, 2, 2, //First row
  4, 2, 4, 4, 4, 2, 2, 2, 2, 2, 4, 2, 4, 4, 4, 2 //Second row
};

int length = sizeof(noteDurations) / sizeof(int);
int thisNote = 0;
int Volume = 0;
char sv = '0';
int AV = 0;

void setup() {
  Serial.begin(9600);
  Wire.begin(1);
}
void loop() {
  thisNote = 0;
  for (thisNote = 0; thisNote <= length; thisNote++) {
    sv = char(Wire.read());
    Volume = int(sv);
    AV = 10 / 6 * Volume;
    Serial.write(Wire.read());
    int noteDuration = 2000 / noteDurations[thisNote];
    toneAC(melody[thisNote], AV, noteDuration);
    delay(noteDuration / 12);
    noToneAC();
  }
}

Open up your IDE, then open up File -> Examples -> Wire -> Slave Receiver and look at the code. Look at the master sender example as well.

The i2c protocol is not asynchronous like RS232. You cannot simply read/write back and forth.

Both A4s and A5s are connected as needed.

You need to connect grounds as well.