arduino/I2C_SLAVE_PHOTORESISTOR/I2C_SLAVE_PHOTORESISTOR.ino

27 lines
484 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()
{
2015-08-26 02:41:39 +02:00
pinMode(13, OUTPUT);
2015-08-25 23:22:27 +02:00
Wire.begin(7); // join i2c bus with address #7
Wire.onRequest(requestEvent); // register event
Serial.begin(9600); //Begin serial communcation
}
void loop()
{
2015-08-26 02:41:39 +02:00
//Serial.println(analogRead(lightPin));
//delay(60000);
2015-08-25 23:22:27 +02:00
}
void requestEvent()
{
2015-08-26 02:47:18 +02:00
Wire.write(analogRead(lightPin));
2015-08-26 02:41:39 +02:00
digitalWrite(13, HIGH);
delay(50);
digitalWrite(13, LOW);
2015-08-25 23:22:27 +02:00
}