Specifications
- Voltage range: 1.1–1.5 V.
- Operating temperature: −20°C to +80°C.
- Peak wavelength: 600 nm.
- Power dissipation: 90 mW.
Overview
The light sensor measures visible light falling on it.
How it works: The sensor uses a photoresistor whose resistance changes with the number of photons that reach it. In a simple voltage divider, this produces an output voltage proportional to the incident light level.
The sensor provides an analog output.
Using the sensor
Connecting
The sensor uses a standard 3-pin connector and plugs into any IN port on the Trackduino controller.
Programming
The sensor blocks are in the Sensors block group.
| Block and generated function | Description |
|---|---|
![]() int cdsAnalog(int port) | Returns a value from 0 to 1023 corresponding to the received light level.int port: port connected to the sensor. |
![]() int cdsLight(int port, int threshold) | Returns TRUE when the received light level is above the threshold.int port: connected port.int threshold: threshold from 0 to 1023. |
![]() int cdsDark(int port, int threshold) | Returns TRUE when the received light level is below the threshold.int port: connected port.int threshold: threshold from 0 to 1023. |
Example project
Turn on a light when it gets dark
Generated code:
void setup()
{
pinMode( OUT1 , OUTPUT );
}
void loop()
{
if (cdsDark(IN1, 500))
{
led ( OUT1 , HIGH );
}
else
{
led ( OUT1 , LOW );
}
}



