/Designs/Spectrograph/SW/test_hw/i2c_light/i2c_light.pde
8,6 → 8,7
{
Wire.begin(); // join i2c bus (address optional for master)
pinMode(3, OUTPUT); // LED pro blikani, aby bylo videt, ze to neco dela
pinMode(5, OUTPUT); // LED pro blikani, aby bylo videt, ze to neco dela
Serial.begin(9600); // Zmerena intenzita osvetleni se bude vypisovat na seriovou linku
}
 
20,16 → 21,25
Serial.print("lux=");
 
// Setup device
digitalWrite(5, HIGH);
 
Wire.beginTransmission(address);
Wire.send(0x00); // sends address
Wire.send(0b11000000); // setup (eye light sensing; measurement range 2 [4000 lx])
Wire.send(0b11000000); // setup (eye light sensing; one time measurement; measurement range 1)
Wire.endTransmission(); // stop transmitting
 
// Delay for measurement
digitalWrite(3, HIGH); // set the LED on
delay(500);
digitalWrite(3, LOW); // set the LED off
delay(500);
{
long n;
for(n=0;n<66000;n++)
{
digitalWrite(5, LOW); // set the LED off
// delay(500);
digitalWrite(5, HIGH); // set the LED on
delayMicroseconds(100);
// delay(500);
}
}
 
 
// Connect to device and set register address
69,6 → 79,7
// Serial.print(data, HEX);
lux+=data*256;
 
/*
Serial.print((unsigned)lux, DEC);
 
Serial.print(" luxIR=");
122,7 → 133,7
Wire.endTransmission(); // stop transmitting
// Serial.print(data, HEX);
lux+=data*256;
 
*/
Serial.println((unsigned)lux, DEC);
 
}