#include // Include the required Wire library for I2C int LED = 10; int x = 0; void setup() { // Define the LED pin as Output pinMode (LED, OUTPUT); // Start the I2C Bus as Slave on address 9 Wire.begin(9); // Attach a function to trigger when something is received. Wire.onReceive(receiveEvent); //bit rate for data transfer over Serial communication Serial.begin(9600); } void receiveEvent(int bytes) { x = Wire.read(); // read one character from the I2C } void loop() { //potentiometer value from sensor Serial.print("X is: "); Serial.println(x); if (x==0){ analogWrite(LED, LOW); } else { analogWrite(LED, HIGH); } delay(100); }