Example - 06 : Sensing the Light (Light Sensor)
WHAT ARE WE DOING HERE?
This example reads the amount of light incident on the Grove-Light Sensor and displays the
reading on the Grove 4-Digit Display. This is similar to the previous example except we are now
using the ambient light sensor instead of the potentiometer rotary angle knob.
THE CIRCUIT
● Grove-Ambient Light Sensor x1
● Grove-4-Digit Display x1
● Grove cable x2
● Grove-Base BoosterPack x1
● LaunchPad Development Kit
Connections:
Plug the Grove-Ambient Light Sensor module
into Analog Grove connector J6 on the
BoosterPack. This will link the SIG pins of the
potentiometer to pin 24 of the LaunchPad.
Plug the Grove-4-Digit Display module into
Grove connector J14 on the BoosterPack.
This will link the 2 SIG pins of the 4 digit
module to pins 38 (DIO) & 39 (CLK) of the
LaunchPad.
CODE
This example is available here: File > sketchbook > LaunchPad_Kit > Grove_Modules >
light_sensor
Note that this code is pretty much identical to the rotary angle example above.
/*
Light Sensor
A simple program that display the value of light incident on the grove-light-sensor
by grove-4-digital-display, this example is similar to grove-rotary-angle-sensor
The circuit:
* grove-4-digital-display attached to dio9&dio10 (IIC plug on Grove Base BoosterPack)
* sig pin of the light sensor to the analog pin
* one side pin (either one) to ground
* the other side pin to VCC
* Note:
批注 [15]: Update file path and add header file to sketch
folder