Infrared Sensor

class compLib.IRSensor.IRSensor

Access the different IR Sensors at top / bottom of the robot

static bottom_left() → bool

Get bottom left infrared sensor status

Returns

True, if sensor detects IR signals

Return type

bool

static bottom_left_analog() → int

Get bottom left infrared sensor value: ranges from 0 to 1023

Returns

10-bit brightness value

Return type

int

static bottom_middle() → bool

Get bottom middle infrared sensor status

Returns

True, if sensor detects IR signals

Return type

bool

static bottom_middle_analog() → int

Get bottom middle infrared sensor value: ranges from 0 to 1023

Returns

10-bit brightness value

Return type

int

static bottom_right() → bool

Get bottom right infrared sensor status

Returns

True, if sensor detects IR signals

Return type

bool

static bottom_right_analog() → int

Get bottom right infrared sensor value: ranges from 0 to 1023

Returns

10-bit brightness value

Return type

int

static top_left_percent() → int

Get top left infrared sensor percentage

Returns

Percentage between 0 and 100

Return type

int

static top_right_percent() → int

Get top right infrared sensor percentage

Returns

Percentage between 0 and 100

Return type

int

Examples

Testing analog sensors

from compLib import IRSensor

ir = IRSensor.IRSensor()

while True:
   print ("left: {}  middle: {}  right: {}".format(ir.bottom_left_analog(), ir.bottom_middle_analog(), ir.bottom_right_analog()))