added status LED to I2C Arduino slave

This commit is contained in:
Johannes Findeisen 2015-08-26 02:41:39 +02:00
commit fcada51f0f

View file

@ -6,6 +6,7 @@ int lightPin = 0;
void setup() void setup()
{ {
pinMode(13, OUTPUT);
Wire.begin(7); // join i2c bus with address #7 Wire.begin(7); // join i2c bus with address #7
Wire.onRequest(requestEvent); // register event Wire.onRequest(requestEvent); // register event
Serial.begin(9600); //Begin serial communcation Serial.begin(9600); //Begin serial communcation
@ -13,11 +14,14 @@ void setup()
void loop() void loop()
{ {
Serial.println(analogRead(lightPin)); //Serial.println(analogRead(lightPin));
delay(1000); //delay(60000);
} }
void requestEvent() void requestEvent()
{ {
Wire.write(analogRead(lightPin)); // respond with message of 6 bytes Wire.write(analogRead(lightPin)); // respond with message of 6 bytes
digitalWrite(13, HIGH);
delay(50);
digitalWrite(13, LOW);
} }