Light Sensor - Tinkerbots

ARDUINO LIBRARY LIGHT SENSOR

The Light Sensor module expands the capabilities of your creation even more. Your robot can e.g. adjust it’s speed based on the surrounding light. You can create cars that fear the dark, or a flower that rises up it’s head when powered with a flashlight. It’s up to you!

FUNCTION OVERVIEW

FUNCTION DESCRIPTION

 

    NAME

TBLightSensor()

    DESCRIPTION

Instance a Module from Type LightSensor. It is neccessary to include the header file.
#include “TBLightSensor.h”

    SYNTAX

TBLightSensor(color);

    PARAMETER

color: Color of the module which is shown during setup.
Values: RED, GREEN, BLUE, MINT, PURPLE, YELLOW, WHITE

    RETURN

None

    EXAMPLE

 

#include „TBLightSensor.h“

TBLightSensor sensor(PURPLE);
byte data = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
data = sensor.getData();
Serial.print(„Sensor Data: „);
Serial.println(data);
}

 

    NAME

getData()

    DESCRIPTION

Receive the sensor value. This sensor returns the intensity of light. The values obtained change based on the environment (e. g. inside/outside).

    SYNTAX

getData();

    PARAMETER

None

    RETURN

Value between 0 and 180. Datatype is byte.

    EXAMPLE

 

#include „TBLightSensor.h“

TBLightSensor sensor(PURPLE);
byte data = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
data = sensor.getData();
Serial.print(„Sensor Data: „);
Serial.println(data);
}