光敏传感器

光敏传感器实质是一个光敏电阻,其阻止会随光线强度的变化而发生变化,并且当光照强烈时,阻值变小;光照减弱时,阻值增大;完全遮挡光线时,阻值最大。

Arduino引脚

模块引脚

A2

S

5V

Vcc

GND

GND

int sensorPin = 2;

int value = 0;

void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600);

}

 

void loop() {

  // put your main code here, to run repeatedly:

  value = analogRead(sensorPin);

  Serial.println(value, DEC);

  delay(50);

}

  

posted @ 2015-11-22 14:49  李琼羽  阅读(696)  评论(0编辑  收藏  举报