Difference between revisions of "The Use of Light Sensor"
From Microduino Wiki
(→Experiment: Detect analog Brightness Value) |
|||
Line 63: | Line 63: | ||
} | } | ||
</source> | </source> | ||
− | * Select the right board from Tools→Serial Port in Arduino IDE and download the program. [[file: | + | * Select the right board from Tools→Serial Port in Arduino IDE and download the program. [[file:uploadlight.JPG|600px|center]] |
+ | [[file:uploadlight1.JPG|600px|center]] | ||
*After the download, you can open the serial monitor. The displayed value reflects the current light intensity. | *After the download, you can open the serial monitor. The displayed value reflects the current light intensity. | ||
− | [[file: | + | [[file:uploadlight3.JPG|600px|center]] |
*Result | *Result | ||
− | The stronger the light is, the greater the output value becomes. Therefore, you can build some projects controlled by light intensity change. | + | The stronger the light is, the greater the output value becomes. Therefore, you can build some projects controlled by light intensity change. |
===Program Debugging=== | ===Program Debugging=== |
Revision as of 02:33, 5 November 2015
ContentsOutlineMicroduino-Light adopts photosensitive resistor. It uses a resistor that is based on semiconductor's photoelectric effect and is able to change along with the intensity of t the incident light. The photosensitive resistor is generally applied in light measurement, light control and photoelectric conversion. 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 |