#include <Wire.h> void receiveEvent(int bytes) while(Wire.available()) char c = Wire.read(); Serial.print(c);
Try the built-in I2C scanner (File → Examples → Wire → Scanner), then hook up a cheap OLED or RTC module. You’ll be amazed at what two wires can do. arduino wire.h library
void loop() delay(100);
Serial.println();
Serial.println(); delay(1000);
// Configure sensor (simplified) Wire.beginTransmission(SENSOR_ADDR); Wire.write(0x26); // Control register Wire.write(0xB9); // Active, 128 samples, 2^8mbar max Wire.endTransmission(); delay(100); #include <Wire
You can also make one Arduino act as a slave. This is useful for multi-processor projects. Master Code (Sends a command): #include <Wire.h> void setup() Wire.begin(); Serial.begin(9600); // Control register Wire.write(0xB9)