

void setup() {
	Serial.begin(9600);
	Serial.setTimeout(10);
}

#define R 2400.f

void loop() {
	long v = 0;
	int cnt = 1000;
	for (int i = 0; i < cnt; ++i) {
		v += analogRead(A0);
	}
	float vv = v / float(cnt);
	float r = (vv * R) / max(0.01f, 1024.f - vv);
	//float lux = (2.86E+08f) * pow(vv, -2.2f) - 1024.f;
	float lux = 65646*exp(-0.018 * vv);
	Serial.print("!adc = "); Serial.print(vv);
	Serial.print(", r = "); Serial.print(r);
	Serial.print(", lux = "); Serial.print(lux);
	Serial.println("");
}
