Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- //#define I2C_SLAVE_1_ADDR 1
- #define I2C_SLAVE_2_ADDR 2
- void setup() {
- Wire.begin(); // join i2c bus (address optional for master)
- Serial.begin(9600);
- Serial.print("Ready");
- }
- char x = 0;
- void loop() {
- if (Serial.available() > 0) {
- x = Serial.read();
- if (x == '0') {
- Wire.beginTransmission(2); // transmit to device #8
- Wire.write('0'); // sends one byte
- Wire.endTransmission(); // stop transmitting
- }
- if (x == '1') {
- Wire.beginTransmission(2); // transmit to device #8
- Wire.write('1'); // sends one byte
- Wire.endTransmission(); // stop transmitting
- }
- if (x == '2') {
- Wire.beginTransmission(2); // transmit to device #8
- Wire.write('2'); // sends one byte
- Wire.endTransmission(); // stop transmitting
- }
- if (x == '3') {
- Wire.beginTransmission(2); // transmit to device #8
- Wire.write('3'); // sends one byte
- Wire.endTransmission(); // stop transmitting
- }
- }
- }
Add Comment
Please, Sign In to add comment