#define LED 13
const float GAMMA =0.7;
const float RL10 =50;
void setup() {
// put your setup code here, to run once:
// 串口
Serial.begin(115200);
pinMode(LED, OUTPUT);
}
// float get_lux(void)
// {
// int analogValue =analogRead(A0);
// float voltage = analogValue/1024*5;
// float resistance = 2000*voltage/(1-voltage/5);
// float lux = pow(RL10*1e3*pow(10,GAMMA)/resistance,(1/GAMMA));
// return lux;
// }
void loop() {
// put your main code here, to run repeatedly:
// float lux = get_lux();
// bool isnearby = lux<50;
// Serial.print("The lux is:");
// Serial.println(lux);
int analogValue = analogRead(A0);
Serial.print(analogValue);
Serial.print("\n");
bool isNearby = analogValue >500;
digitalWrite(LED, isNearby);
delay(100);
}