Component: Light Sensor (101020132) (Grove)

From Flowcode Help
Jump to navigationJump to search


Author Matrix Ltd
Version 1.0 (Release)
Category Grove


Image Light Sensor (101020132) component

The Light sensor module is a simple analogue photo transistor. Used to detect the intensity of the indoor light. The light sensor contains a photoresistor to detect light intensity. The resistance of the photoresistor decreases as light intensity increases. This means that the brighter the light is, the higher the voltage so that means the output value increases corresponding to the brightness of light.

Make sure it’s connected to the right channel in flowcode. You can use component macros to call the value it records as a byte, an integer, a string or even as a direct voltage, and there are also macros that allow you to take the average reading as a byte or an integer.

Examples

No additional examples


Downloadable macro reference

GetString

Reads the ADC as a direct voltage and returns as as tring

Parameters

This macro has no parameters


Return value

STRING


GetAverageByte

Function call to read the ADC as a byte average sample over time

Parameters

BYTE NumSamples
BYTE DelayUs
Number of micro seconds in between taking each sample


Return value

BYTE


GetAverageInt

Function call to read the ADC as a full width average sample over time

Parameters

BYTE NumSamples
BYTE DelayUs
Number of micro seconds in between taking each sample


Return value

UINT


GetVoltage

Reads the ADC as a direct voltage

Parameters

This macro has no parameters


Return value

FLOAT


GetInt

Blocking call to read the ADC at full bit depth

Parameters

This macro has no parameters


Return value

UINT


GetByte

Blocking call to read the ADC as a byte

Parameters

This macro has no parameters


Return value

BYTE


Simulation macro reference

This component does not contain any simulation macros


Property reference

Tang Color

This property is of type Color picker and can be referenced with the variable name tang_col.

Colour of the moving part of the slider.

Marker Color

This property is of type Color picker and can be referenced with the variable name mark_col.

Colour of the marker line across the slider tang.

Scope Traces

This property is of type True or false and can be referenced with the variable name ScopeTraces.

Selects if the scope traces are automatically generated or not

Channel

This property is of type Single analog pin and can be referenced with the variable name channel.

Analogue input channel - which pin is the analogue input conected to?

VRef voltage

This property is of type Signed integer and can be referenced with the variable name vrefvol.

Used by the GetVoltage or GetString component macros to take an ADC reading and convert it into a Voltage.

+VRef voltage x 10mV

Default 500 = 5.0V

VRef option

This property is of type Fixed list of ints and can be referenced with the variable name vrefop.

Defines what is used as the ADC maximum reference. ADC Range = GND to VRef Voltage.

VDD - Defines the microcontrollers power supply pin as the max reference,

VREF+ Pin - Dedicated pin on the microcontroller to allow for a variable reference voltage.

Conversion speed

This property is of type Fixed list of ints and can be referenced with the variable name convspd.

Clock setting to select how fast the ADC peripheral will perform an ADC conversion.

The FRC setting is based on a RC time base and so will vary with temperature and pressure.

Other settings are generally based on divisions of the master clock.

Aquisition cycles

This property is of type Signed integer and can be referenced with the variable name actime.

Number of micro seconds to wait for the ACD input to charge before starting the analogue sample.

Bit Depth

This property is of type Signed integer and can be referenced with the variable name bits.

Maximum number of digital bits the ADC can sample.

8 bit = ADC range 0 - 255

10 bit = ADC range 0 - 1023

12 bit = ADC range 0 - 4095