原理链接
https://www.yiboard.com/thread-901-1-1.html
代码文件:
const int led=3; // variable which stores pin number
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT); //configures pin 3 as OUTPUT
}
void loop()
{
int sensor_value = analogRead(A0);
Serial.println(sensor_value);
if (sensor_value < 150)// the point at which the state of LEDs change
{
digitalWrite(led, HIGH); //sets LEDs ON
}
else
{
digitalWrite(led,LOW); //Sets LEDs OFF
}
}
光照强时:
光照弱时: