/Designs/Data_loggers/LuxmetrSD/SW/Arduino/luxmetr/luxmetr.pde
30,8 → 30,14
#define LIGHT_RANGE3 3
#define LIGHT_RANGE4 4
 
char filename[13];
int data = 0;
int light_sensor_setup;
 
void setup()
{
int count=0;
 
Wire.begin(); // join i2c bus (address optional for master)
 
pinMode(3, OUTPUT); // LED pro blikani, aby bylo videt, ze to neco dela
50,12 → 56,18
return;
}
Serial.println("card initialized.");
Serial.print("searching for files...");
do
{
sprintf(filename,"Lux%d.txt",count);
count++;
}
while(SD.exists(filename));
Serial.print("Using ");
Serial.println(filename);
}
 
int data = 0;
int light_sensor_setup;
 
void led_blink()
{
digitalWrite(3, HIGH); // set the LED on
64,7 → 76,6
delay(500);
}
 
 
int set_light_sensor(int mode)
{
int command;
164,7 → 175,7
led_blink(); // Delay for measurement
luxVIS=get_light_measurement();
 
time=millis()/1000;
time=millis()/1000.0;
set_light_sensor(SENSE_IR); // setup sensor for infrared measuring
led_blink(); // Delay for measurement
172,7 → 183,7
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("datalog.txt", FILE_WRITE);
File dataFile = SD.open(filename, FILE_WRITE);
 
// if the file is available, write to it:
if (dataFile) {
194,7 → 205,8
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
Serial.print("error opening ");
Serial.println(filename);
}
}