Comment on page
Out of the box setup: your IR Seeker is ready to use, plug it in and it will appear as if it is a colour sensor (unless it is an older V2 firmware). Rather than colour, the board will report the direction of the ball using the same pattern as a clock from the green value of the sensor.
Standard Mode: The IR Seeker will make use of the distance sensor block, a basic program to show the current direction of the ball is shown below.
Advanced Mode: The IR Seeker will appear as a colour sensor. A basic program to show the current direction and signal strength is shown below.
The signal strength block uses the 'more sensors' additional block, this can be added by clicking the icon in the bottom left hand corner:
Then select the 'More Sensors' option:
From here you will see some more blocks:
The IR Seeker will appear as if it is a Distance Sensor, we use the method get_distance_cm() to return the direction of the ball.
hub = PrimeHub()
ir_seeker = DistanceSensor('A')
#write the direction to the screen every second.
The main issue with using the IR Seeker as a distance sensor is that it can only provide the ball direction. Often the signal strength is important as well, however we need to use the advanced functionality to use both the ball direction and ball distance (signal strength).
First step is to ensure the switch is set to advanced mode:
DIP Switch 1 - On - DIP Switch 2 - On
ir_seeker = hub.port.C.device #CHANGE TO YOUR PORT NUMBER
data = ir_seeker.get()
direction = data
strength = data
The code will connect to the sensor and then issue a mode change command, the sensor can then be read and the raw values returned and used.