This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:hardware2:sensors_light [2023/06/29 20:31] – ktokarz | en:iot-open:hardware2:sensors_light [2023/11/23 12:37] (current) – pczekalski | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Light Sensors ====== | ||
| + | {{: | ||
| + | == Photoresistor == | ||
| + | |||
| + | A photoresistor is a sensor that perceives light waves from the environment. The resistance of the photoresistor is changing depending on the intensity of light. The higher the intensity of the light, the lower the sensor' | ||
| + | \\ | ||
| + | <figure phtoresistor1> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <figure phtoresistor2> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <figure phtoresistor3> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | As shown in the figure {{ref> | ||
| + | <code c> | ||
| + | //Define an analog A0 pin for photoresistor | ||
| + | int photoresistorPin = A0; | ||
| + | //The analogue reading from the photoresistor | ||
| + | int photoresistorReading; | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | //Begin serial communication | ||
| + | Serial.begin(9600); | ||
| + | // | ||
| + | pinMode(photoresistorPin, | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | //Read the value of the photoresistor | ||
| + | photoresistorReading = analogRead(photoresistorPin); | ||
| + | //Print out the value of the photoresistor reading to the serial monitor | ||
| + | Serial.println(photoresistorReading); | ||
| + | delay(10); //Short delay | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | == Photodiode == | ||
| + | A photodiode is a sensor that converts light energy into electrical current. A current in the sensor is generated by exposing a p-n junction of a semiconductor to the light. Information about the light intensity can be determined by measuring a voltage level. Photodiodes react to changes in light intensity very quickly, so they can be used as receivers of light-based data transmission systems (e.g. fibre data communication). Solar cells are just large photodiodes. A symbol, sample photodiode and connection circuit are present in figures {{ref> | ||
| + | Photodiodes are used as precise light-level sensors, receivers for remote control, electrical isolators (optocouplers), | ||
| + | \\ | ||
| + | <figure photodiode1> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <figure photodiode2> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <figure photodiode3> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | Although the photodiode can generate current, the schematic in figure {{ref> | ||
| + | An example code: | ||
| + | <code c> | ||
| + | //Define an analog A0 pin for photodiode | ||
| + | int photodiodePin = A0; | ||
| + | //The analogue reading from the photodiode | ||
| + | int photodiodeReading; | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | //Begin serial communication | ||
| + | Serial.begin(9600); | ||
| + | // | ||
| + | pinMode(photodiodePin, | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | //Read the value of the photodiode | ||
| + | photodiodeReading = analogRead(photodiodePin); | ||
| + | //Print out the value of the photodiode reading to the serial monitor | ||
| + | Serial.println(photodiodeReading); | ||
| + | delay(10); //Short delay | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | == Phototransistor == | ||
| + | The phototransistor is a typical bipolar transistor with a transparent enclosure that exposes the base-emitter junction to light. In a bipolar transistor, the current that passes through the collector and emitter depends on the base current. In the phototransistor, | ||
| + | Phototransistors are used as optical switches, proximity sensors and electrical isolators.\\ | ||
| + | A symbol, sample phototransistor device, and circuit are present in figures {{ref> | ||
| + | \\ | ||
| + | <figure phototransistor1> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <figure phototransistor2> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <figure phototransistor3> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | An example code: | ||
| + | <code c> | ||
| + | //Define an analog A1 pin for phototransistor | ||
| + | int phototransistorPin = A1; | ||
| + | //The analogue reading from the phototransistor | ||
| + | int phototransistorReading; | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | //Begin serial communication | ||
| + | Serial.begin(9600); | ||
| + | // | ||
| + | pinMode(phototransistorPin, | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | //Read the value of the phototransistor | ||
| + | phototransistorReading = analogRead(phototransistorPin); | ||
| + | //Print out the value of the phototransistor reading to the serial monitor | ||
| + | Serial.println(phototransistorReading); | ||
| + | delay(10); //short delay | ||
| + | } | ||
| + | </ | ||