Ardumotive Arduino Greek Playground
  • Home
    • About us
    • Contact
    • License
  • Arduino
    • Tutorials
    • Workshop
  • Raspberry Pi
  • DIY 3D Printer
  • News
    • Events >
      • Unboxing & Review
    • Blog
The 1st Arduino Playground in Greece - Open Source Hardware

Light Sensor

Available Languages
Picture
Picture

Introduction 

Picture
The Grove - Light sensor integrates a photo-resistor(light dependent resistor) to detect the intensity of light. The resistance of photo-resistor decreases when the intensity of light increases. A dual OpAmp chip LM358 on board produces voltage corresponding to intensity of light(i.e. based on resistance value). The output signal is analog value, the brighter the light is, the larger the value.

This module can be used to build a light controlled switch i.e. switch off lights during day time and switch on lights during night time.

What we need and connection

For this tutorial we will need:
  • Arduino UNO
  • Grove Base Shield
  • Light Sensor
  • LCD RGB Backlight (Connect Grove-LCD RGB Backlight to port I2C of Grove-Base Shield)
Picture

The code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;

const int colorR = 0;
const int colorG = 250;
const int colorB = 0;

void setup()
{
  // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);
    
    lcd.setRGB(colorR, colorG, colorB);
    
    // Print a message to the LCD.
    lcd.print("Hello Ardumotive");
    delay(1500);
}

void loop()
{

  int value = analogRead(A0);
  value = map(value, 0, 800, 0, 10);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Value: ");
  lcd.setCursor(0,1);
  lcd.print(value);
  delay(1000);
}
Download the code from here and open it with Arduino IDE. Libraries are also inside the ZIP file.
grove-_light_sensor.zip
File Size: 30 kb
File Type: zip
Download File

Well done!

Picture
You have successfully completed one more Arduino Grove tutorial.

I hope you liked this, let me know in the comments.
Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates