Infrared Sensor
- class compLib.IRSensor.IRSensor
Access the different IR Sensors of the robot
- static read(sensor: int) int
Read one infrared sensor
- Parameters
sensor – Which sensor to read. Between 1 and 5
- Raises
IndexError
- Returns
Sensor value. 10 bit accuracy
- Return type
int
- static set(sensor: int, on: bool)
Turn on / off a IR emitter
- Parameters
sensor – Which sensor to read. Between 1 and 5
- Raises
IndexError
Examples
Testing analog sensors
from compLib import IRSensor
while True:
print ("left: {} middle: {} right: {}".format(IRSensor.read(1), IRSensor.read(3), IRSensor.read(5)))