Embedded System - Arduino

 

 

 

 

Light Sensor

 

In this tutorial, I will show you an example of utilizing an analog sensor. The sensor that I picked is a light sensor which measure the intensity of light and output the intensity in the form of Analog voltage.

The module is from SEPP ligh sensor and the connection diagram is as shown below (very simple).

 

 

You can get the information of this device in the following web site, but for this module you might not need any special information and you would not need any special libraries. You can operate this sensor just by using defaul Arduino functionality. (However, I always recommend you to visit the web site of the module manufacturere and check if you can get the details information about the module. In some case, you may get in trouble after you buy it if you don't get the detailed information anywhere).

 

http://osepp.com/products/sensors-arduino-compatible/light-sensor-module/

 

 

Program for this tutorial is very simple as shown below. It just read Light intensity value from the analog input pin to which the output of the sensor is connected and send it to PC via Serial port.

 

int photocellPin = A0;    // photocell sensor input

int photocellValue = 0;

 

void setup() {

 

Serial.begin(9600);  // This is to initialize the serial port. If you are not familiar with utilizing Arduino Serial port

                           // refer to Serial Basic tutorial.

 

}

 

void loop() {

  // read the value from the sensor:

  photocellValue = analogRead(photocellPin);  

 

  Serial.print("Sensor Value =");

  Serial.println( photocellValue);

 

  delay(1000);

           

}

 

If you run this program and open up Arduino COM port monitor, you would see the sensor values are printed once in a second as shown below.