Light Intensity Detection

From Microduino Wiki
Jump to: navigation, search

Function of the Module

  • Please refer to: The Use of Light Sensor
    • As an analog input sensor, the values it detect have a certain range, which is 0-1023 theoretically. Besides, the value is changeable.

Overview

To use the light sensor to detect light intensity and check data in the serial monitor.

Bill of Material

  • Module
Module Number Function
mCookie-CoreUSB 1 Core board
mCookie-Hub 1 Sensor pin board
Microduino-Light 1 Light intensity detection sensor
  • Other Hardware Equipment
    • One USB cable USB
Module-light.jpg

Hardware Buildup

  • Setup 1:Connect the light sensor with the A0 analog port of the Hub. Users can change the analog port to A2 or A4 on your own.
  • Setup 2:Connect the CoreUSB, Hub and the light sensor to the computer with a USB cable.
MCookie-Light-pc.JPG

Mixly Programming

  • Step1:Since using serial monitor, we need to find "Serial Communication" from "Communication" item.
Mixly Serial.jpg
  • Step2:"Serial Communication" description.
  • Step3:Light sensor is an input device and the value of the sound has a certain range while the returned data is digital quantity, based on which we can find and drag out the digital input and output from "Input/Output".
  • Analog Input" description.
  • Overall code description.

Debugging

  • Step1:Select the right board card(Core USB 32U4) and COM port(Recognized automatically by default).
Mixly board COM.jpg
  • Step2:Open the serial monitor. 。
Mixly COMXX.jpg
  • Step3:Check if the serial baud rate is the same with the pre-set one.
Mixly COMXX ok.jpg
  • Step4:Check the data and you'll find: When there is no light around the sensor, the data is nearly 0. And the data is getting bigger along with the light intensity becoming higher, the maximum is about 1000 by using a flashlight aiming at the sensor.

Extension

  • To trigger and perform some tasks by judging the sound value.
  • Example code
  • "Logic" description
  • "Comparison" description