Hi all,
So I have my two Arduino Unos connected over I2C. I have no code for this project right now, though I know that the I2C bus works since I've used it before. What I want to do is to set two different event handlers on my Slave, meaning that it does different things based on what it is sent.
To clarify, what I've used before and what everyone seems to use is this within their Slave code:
void setup() {
Wire.begin([i]address[/i]);
Wire.onRecieve(receiveEvent);
}
void receiveEvent(int howManyBytes) {
// Do something
}
What I want is something like this:
void setup() {
Wire.begin();
Wire.onReceive1(receiveEvent1);
Wire.onReceive2(receiveEvent2);
}
void receiveEvent1 (int howMany1) {
// Do something
}
void receiveEvent2 (int howMany2) {
// Do something else
}
The reason this might be helpful is if the Slave has two motors, and one event makes the first one go forward, and the second makes the second motor go forward. (Not what I'll be using it for, but just some context).
Is the same vein, would it be possible to setup two different requestEvents()?
I know that a way around this would be to have one receiveEvent() with statements to do things based on what it received, and with the requestEvent(), just send all the data at once in multiple bytes. But I'm wondering if it's doable with multiple event handlers.
Thanks.