Difference between revisions of "The Use of Light Sensor"
From Microduino Wiki
(Major Edits) |
|||
Line 43: | Line 43: | ||
===Preparation=== | ===Preparation=== | ||
− | *Setup | + | *Setup 1: Connect Microduino-Light and the A0 analog port of the Hub. |
[[file:mCookie-pir-sensor.JPG|600px|center]] | [[file:mCookie-pir-sensor.JPG|600px|center]] | ||
− | *Setup | + | *Setup 2: Connect the CoreUSB, Hub and Light to the computer with a USB cable. |
[[file:mCookie-Light-pc.JPG|600px|center]] | [[file:mCookie-Light-pc.JPG|600px|center]] | ||
Line 76: | Line 76: | ||
===Program Debugging=== | ===Program Debugging=== | ||
− | * | + | *"#define sensorPin A0" defines sensor interface. |
− | * | + | *Use"analogRead(sensorPin);"function to read the output analog value of the sensor and therefore, to judge light intensity change. |
==Application== | ==Application== |
Latest revision as of 06:43, 30 September 2016
ContentsOutlineThe Microduino Light Sensor uses a photosensitive resistor to detect the amount of ambient light present. The sensor is effectively a resistor that changes in value as the light intensity surrounding it changes. The sensor will output a voltage value that corresponds to the amount of light detected by the sensor. Couple the sensor to an LED and you have a smart light that illuminates a room as it gets dark! Specification
DevelopmentEquipment
Preparation
Experiment: Detect analog Brightness Value
#define sensorPin A0
int state;
void setup()
{
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void loop()
{
state = analogRead(sensorPin);
Serial.print("state:");
Serial.println(state);
delay(100);
}
The stronger the light is, the greater the output value becomes. Therefore, you can build some projects controlled by light intensity change. Program Debugging
Application
Video |