#include <Wire.h>
String dataSetup;
int setStatus = 0;
int address = 0;
float calibration = 0.00;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Enter: ");
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()) {
if (setStatus == 0) {
dataSetup = Serial.readStringUntil('\n');
if (dataSetup == "setting") {
setStatus = 1;
Serial.println("\nWelcome to the setting Mode\n 1. Setting I2C address\n 2. Enter the voltage calibration");
}
}
else if (setStatus == 1) {
dataSetup = Serial.readStringUntil('\n');
if (dataSetup == "1") {
setStatus = 2;
Serial.println("\nEnter The I2C address you want for this slave:");
}
else if (dataSetup == "2") {
setStatus = 3;
Serial.println("\nEnter The voltage calibration for this slave:");
}
}
else if (setStatus == 2) {
setStatus = 0;
address = Serial.parseInt();
Serial.println(address);
Wire.begin(address);
}
else if (setStatus == 3) {
setStatus = 0;
String kalibration = Serial.readString();
}
}
if (setStatus == 0) {
Serial.print("My Address is: ");
Serial.println(address);
Serial.print("My Calibration is: ");
Serial.println(calibration);
delay(1000);
}
delay(100);
}