Light Sensor

Other libraries:
Powerbrain
Motor
Pivot
Twister
IR Sensor
Light Sensor

Each module (with the powerbrain as an exception) is assigned a specific color by the powerbrain. Connecting an arduino-powerbrain (!) via USB cable to a PC activates the colors on all connected modules. Use these to initialize the objects in your sketches correctly.

E.g. after plugging in the USB cable, a connected Motor lights up a purple LED. You will have to initialize this motor in the sketch with "TBMotor variableMotorName(PURPLE);"

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);
        }