Spike Prime
Firmware Update:
We highly recommend updating to the latest firmware version. This will ensure that your sensor continues to work with Spike.
The 2023 Spike release is in Beta testing and will be released mid-late Feb 2023.
Please also note that the latest version of Spike may cause the sensor to not be seen on high speed ports E and F, please try the sensor on ports A, B, C or D.
Out of the box setup: your IR Seeker is ready to use, plug it in and it will appear as if a distance sensor has been plugged in. Rather than distance, the board will report the direction of the ball using the same pattern as a clock.
The small switches on the board are used to turn on functionality. The Board Feature Switches page has more details on these settings. These settings can help you to get more features from the board.
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')
while True:
#write the direction to the screen every second.
print(ir_seeker.get_distance_cm())
wait_for_seconds(1)
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
import hub
ir_seeker = hub.port.C.device #CHANGE TO YOUR PORT NUMBER
ir_seeker.mode(5, bytes([0,0,0,0]))
while True:
data = ir_seeker.get()
direction = data[0]
print("Direction", direction)
strength = data[2]
print("Strength", strength)
wait_for_seconds(1)
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.
Last modified 1mo ago