Ir Sensor - Tinkerbots

ARDUINO LIBRARY IR SENSOR

More advanced robotics require autonomous reactions. Your robot will need eyes to see obstacles or detect an object to grab. The IR Sensor module measures infrared light to determine the distance to the next object.

FUNCTION OVERVIEW

FUNCTION DESCRIPTION

 

    NAME

TBIRSensor()

    DESCRIPTION

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

    SYNTAX

TBIRSensor(color);

    PARAMETER

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

    RETURN

None

    EXAMPLE

 

#include „TBIRSensor.h“

TBIRSensor 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 distance to an object. 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 „TBIRSensor.h“

TBIRSensor sensor(PURPLE);
byte data = 0;

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

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