Sensor Data Filling an Array on the Slave

For my project I have two Megas communication via serial. The one collects diameter measurements and then sends them over to another mega for thermal compensation. Currently I am trying to collect multiple diameters into an array because they will eventually be paired with specific length measurements. The current section of my code attempting this is:

if (Serial2.available()>0)
  {
    byte m = Serial2.readBytesUntil('\n', myData, 10);
    myData[m] = '\0';
    diameterin = atof(myData);
    Serial.println(diameterin,4);
    memset(myData, 0, 10);
    for (int i=0; i<10; i++);{
    Diameter[i] = diameterin;
    Serial.println(Diameter[i],4);
    }
  }

I feel like I am on the right track but am missing something.

Where in the advice given did You read to post snippets? Sending snippets is not recommended.
What do You feel is missing? What's the outcome when running the project?

I believe that my for loop is not indexing correctly and storing values in the array. Here is my entire slave code that is receiving diameters and performing temperature compensation based off different buttons.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <dht.h>
float dL = 0;
float dT = 0;
float a1 = 0;
float a2 = 0;
float a3 = 0;
float a4 = 0;
float a5 = 0;
float diaAdjusted = 0;
float TF = 0; //Temp of part
float RF = 0; //Room Temp
float diameterin;
int i = 0;
char myData[5] = {0};
int Length[10];
int Diameter[10];
const int ledPin1 = 13; //Material 1
const int ledPin2 = 11; //Material 2
const int ledPin3 = 9; //Material 3
const int ledPin4 = 7; //Material 4
const int ledPin5 = 5; //Material 5
const int buttonPin1 = 12;
const int buttonPin2 = 10;
const int buttonPin3 = 8;
const int buttonPin4 = 6;
const int buttonPin5 = 4;

int buttonstate1 = 0;
int buttonstate2 = 0;
int buttonstate3 = 0;
int buttonstate4 = 0;
int buttonstate5 = 0;

LiquidCrystal_I2C lcd(0x27, 20, 21);
dht DHT;
#define DHT11_PIN 3
void setup() {
  Serial.begin(9600);
  Serial2.begin(9600);
  lcd.init();
  lcd.backlight();
  pinMode(buttonPin1, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);
  pinMode(buttonPin3, INPUT_PULLUP);
  pinMode(buttonPin4, INPUT_PULLUP);
  pinMode(buttonPin5, INPUT_PULLUP);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
}

void loop() {
  if (Serial2.available()>0)
  {
    byte m = Serial2.readBytesUntil('\n', myData, 10);
    myData[m] = '\0';
    diameterin = atof(myData);
    Serial.println(diameterin,4);
    memset(myData, 0, 10);
    for (int i=0; i<10; i++);{
    Diameter[i] = diameterin;
    Serial.println(Diameter[i],4);
    }
  }
  buttonstate1 = digitalRead(buttonPin1);
  buttonstate2 = digitalRead(buttonPin2);
  buttonstate3 = digitalRead(buttonPin3);
  buttonstate4 = digitalRead(buttonPin4);
  buttonstate5 = digitalRead(buttonPin5);
  int chk = DHT.read11(DHT11_PIN);
  TF = (DHT.temperature * 1.8) + 32;
  lcd.setCursor(0,2);
  lcd.print("T= ");
  lcd.setCursor(4,2);
  lcd.print(TF);
  Serial.println(TF);
  if (buttonstate1 == LOW) {
    Serial.println("button 1");
    digitalWrite(ledPin1, HIGH);
    dT = TF - RF;
    dL = diameterin * dT * a1;
    diaAdjusted = diameterin - dL;
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Material 1");
    lcd.setCursor(0, 1);
    lcd.print("Dia(in)= ");
    lcd.setCursor(9, 1);
    lcd.print(diaAdjusted,4);
  }
  else {
    digitalWrite(ledPin1, LOW);

  }
  if (buttonstate2 == LOW) {
    Serial.println("button 2");
    digitalWrite(ledPin2, HIGH);
    dT = TF - RF;
    dL = diameterin * dT * a2;
    diaAdjusted = diameterin - dL;
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Material 2");
    lcd.setCursor(0, 1);
    lcd.print("Dia(in)= ");
    lcd.setCursor(8, 1);
    lcd.print(diaAdjusted,4);
  }
  else {
    digitalWrite(ledPin2, LOW);

  }
  if (buttonstate3 == LOW) {
    Serial.println("button 3");
    digitalWrite(ledPin3, HIGH);
    dT = TF - RF;
    dL = diameterin * dT * a3;
    diaAdjusted = diameterin - dL;
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Material 3");
    lcd.setCursor(0, 1);
    lcd.print("Dia(in)= ");
    lcd.setCursor(8, 1);
    lcd.print(diaAdjusted,4);
  }
  else {
    digitalWrite(ledPin3, LOW);

  }
  if (buttonstate4 == LOW) {
    Serial.println("button 4");
    digitalWrite(ledPin4, HIGH);
    dT = TF - RF;
    dL = diameterin * dT * a4;
    diaAdjusted = diameterin - dL;
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Material 4");
    lcd.setCursor(0, 1);
    lcd.print("Dia(in)= ");
    lcd.setCursor(8, 1);
    lcd.print(diaAdjusted,4);
  }
  else {
    digitalWrite(ledPin4, LOW);

  }
  if (buttonstate5 == LOW) {
    Serial.println("button 5");
    digitalWrite(ledPin5, HIGH);
    dT = TF - RF;
    dL = diameterin * dT * a5;
    diaAdjusted = diameterin - dL;
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("Material 5");
    lcd.setCursor(0, 1);
    lcd.print("Dia(in)= ");
    lcd.setCursor(8, 1);
    lcd.print(diaAdjusted,4);
  }
  else {
    digitalWrite(ledPin5, LOW);

  }
   
}

The outcome of the project is to measure the diameters and length of long cylindrical parts.

In setup the same diameter, read from Serial, is diploid into all 10 cells of the array.

Change );{ to ) {

Are you wanting to transmit 10 diameters from the first Mega to the second Mega? If so, how do you know which is the first diameter? In other words what if the second Mega starts receiving in the middle of a transmission from the first Mega? How would they ever sync up? The code below only receives one diameter.

One more dumb question: Why do you need 2 Megas? Is the data collection Mega at a significant distance from the buttons/display Mega?

in the above statement the ; terminates the for(), i.e. it does nothing 10 times
the following {..} statement is then executed once
try removing the ;, e.g.

for (int i=0; i<10; i++) {

when you post code also post a copy of the serial monitor output indicating where the results are not as expected

The plan is one of the Megas will be connected to the moving sensor arm and the other will be by the controls at one end of the table. The entire length of travel is 14 ft.

I will try this and see if it produces the results I need. I will also post an image of the serial monitor of the data being produced. Also, sorry I have been just teaching myself along the way how to do all of this.

avoid posting images of code, serial monitor output, etc
copy text and paste it into the post (using code tags </>)

Will do.

    for (int i=0; i<10; i++);{
    Diameter[i] = diameterin;
    Serial.println(Diameter[i],4);
    }

Even if you remove the semicolon as previously noted then this for loop will put the same value in all 10 levels of the array which I assume is not what you want

To add to the confusion, Diameter is declared as an an array of ints but diameterin is a float

So should I declare the Diameter array as a float, and how would I make it to fill a different value in different places?

If you want to store floats in the array then, yes, it must be declared as float

To store different values in each level of the array you need to read a value, save it in the array at the current index level then increment the index and keep going until you have saved values in all of the array levels

Will I need to add another line like

i =+ 1

So that it will continue to index the for loop?

You certainly need to increment the array index variable before save a new value. There are several ways to do it such as

i = i + 1;
i++;
i+=1;

Each of them adds one to i. Use whatever method suits you

What is vital is that you do not write to a location outside of the array otherwise all bets are off and the sketch will almost certainly not work