Hi I am trying to send multiple things over I2C (only x and Trims at the moment) when input 3 on the master is high
x will end up being a value between 1 and 101, however just for testing it will be 0, 3, 4 over I2C and then can be set to 10 with the master.
Trims will be a value between 0 and 255 from an analog input 0 on the slave
I can get both of them working by them selves however when I try to do both at once only one will come through.
I have the following code
Wire.begin(); // Start I2C as Master
Wire.requestFrom(5,4); //Also not sure how many bits I should be requesting
x = Wire.read();
//Trims = Wire.read();
Serial.print("x = ");
//Serial.print("Trims = ");
Wire.begin(5); // Start I2C as slave with address 5
Trims = analogRead(0);
map(Trims, 0, 1024, 0, 255);
constrain(Trims, 0, 255);
else if(digitalRead(4)==HIGH) x=4;
All I have been doing to include or remove x or Trims is add or remove // where needed.
Not sure if I am going about this the right way or not.
Any help with this would be appreciated.