Light Sensor

Once you have mastered basic function you can start experimenting with advanced features of Sania Board. Get familiar with Analog to Digital Converters. We have a MCP3002 Analog to  Digital Converter on Board. To show how it works, we have included a photo Resistor PDV-P8104. As the light intensity incident on it changes, the value of the resistor and hence the voltage input to MCP3002 changes. This can be read by Raspberry Pi.

Following is the schematic of light sensor connected to Raspberry pi.

 

This is the location of the Light sensor on the board. 

Following python code can be used to turn the Light Sensor.

1
2
3
4
5
6
7
import RPi.GPIO as GPIO
 
GPIO.setmode(GPIO.BCM)
GPIO.setup(4,GPIO.IN)
 
for i in range(0,5):
    print GPIO.input(4)