![]() Then wire both Arduinos ground to ground. The code would just read pin1 and set led1 opposite and the same for pin2/led2. I would program the controller with the leds to have 2 pins work as INPUT_PULLUP and assign 1 led to each. Int x = Wire.read() // receive byte as an integer While(1 < Wire.available()) // loop through all but the lastĬhar c = Wire.read() // receive byte as a character this function is registered as an event, see setup() function that executes whenever data is received from master Serial.begin(9600) // start serial for output Wire.onReceive(receiveEvent) // register event Wire.begin(4) // join i2c bus with address #4 Refer to the "Wire Master Writer" example for use with this Receives data as an I2C/TWI slave device Wire.endTransmission() // stop transmitting Wire.beginTransmission(4) // transmit to device #4 Wire.begin() // join i2c bus (address optional for master) This example code is in the public domain. Refer to the "Wire Slave Receiver" example for use with this Writes data to an I2C/TWI slave device ![]() I'm trying to somehow use the MasterWriter code with one slave but I really don't know how to write the code for it, is there anyone who has some knwledge about this who can help me? Atm i'm stuck with this: ![]() Basically we got 2 arduinos, one which consists with 2 Led-lights, and the other one consisting 2 buttons which I wanna control the lights with. So basically i'm doing a project in school and i'm kinda stuck. ![]()
0 Comments
Leave a Reply. |