> For the complete documentation index, see [llms.txt](https://cavedu.gitbook.io/linkit-7697/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cavedu.gitbook.io/linkit-7697/linkit-7697-development-guide-for-arduino-ide/tutorial/light-sensor-lm358.md).

# Light Sensor (LM358)

The Grove Light sensor integrates a photoresistor (light dependent resistor) to detect the intensity of light. The resistance of photoresistor decreases when the intensity of light increases. A dual OpAmp chip LM358 on board produces a voltage corresponding to the intensity of light (based on resistance value). The output signal is an analog value. When the light is brighter, the value becomes larger. Please check [the official WiKi](http://wiki.seeed.cc/Grove-Light_Sensor/) for details.

### Setup and Execution <a href="#lightsensor-lm358-setupandexecution" id="lightsensor-lm358-setupandexecution"></a>

1. Download [the sketch file](https://github.com/Seeed-Studio/Light_Sensor/blob/master/examples/Light_Sensor/Light_Sensor.ino) for the light sensor example.
2. Open the downloaded **Light\_Sensor.ino** with the Arduino IDE.
3. Modify **line 20** from 1023 to **4095** to fit the 12-bit ADC output of LinkIt 7697, for example:

   ```
   void loop()
   { 
       int sensorValue = analogRead(LIGHT_SENSOR); 
       Rsensor = (float)(4095-sensorValue)*10/sensorValue; 
       Serial.println("the analog read data is ");
   ```
4. Click the **Upload** icon to compile and upload the sketch file to the board.
5. Open the serial monitor (with baud rate **9,600**) and reset the board to execute the application. You should be able to see the output as below:

![](https://3972650740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY4gduUSLWOCI23CXUWej%2Fuploads%2FIGlLSpHp2MQwO1DHjrrO%2Flight_sensor.png?alt=media\&token=fde1a19b-422d-4c09-9648-d289f32f5cf9)
