arduino/I2C_SLAVE_PHOTORESISTOR/I2C_SLAVE_PHOTORESISTOR.ino

23 lines
427 B
Arduino
Raw Normal View History

2015-08-26 01:39:01 +02:00
// Written 2015 by Johannes Findeisen <you@hanez.org>
2015-08-25 23:22:27 +02:00
#include <Wire.h>
int lightPin = 0;
void setup()
{
Wire.begin(7); // join i2c bus with address #7
Wire.onRequest(requestEvent); // register event
Serial.begin(9600); //Begin serial communcation
}
void loop()
{
Serial.println(analogRead(lightPin));
delay(1000);
}
void requestEvent()
{
Wire.write(analogRead(lightPin)); // respond with message of 6 bytes
}