Skip to main content

Top sensor

The top sensor is similar to a side sensor except it is … on top of OLEM. This means it will be sensing mostly player hands and can be used easily for user input.

As for the other sensors, the signal is already processed by our API and it is possible to :

  • Get the sensor value in LSB or percent
  • Check if a hand is in range

Example​

The LEDs turn on while a hand is above the sensor, and the signal is printed.

import olem

start = olem.get_time_ms()
while olem.get_time_ms() - start < 20000:
print(str(olem.ir_top_get_sensor_percent()) + "%")

if olem.ir_top_is_hand_present():
olem.led_on(olem.LEDALL, "#FFFFFF")
else:
olem.led_off(olem.LEDALL)

olem.delay_ms(250)

Functions​

ir_top_is_hand_present()​

Check if a hand is above the top sensor. It can be used as a button for the players.

Returns: True if a hand is detected, False otherwise

ir_top_get_sensor_value()​

Returns: filtered signal of the top sensor in ADC units (LSB), it increases when a hand gets closer

ir_top_get_sensor_percent()​

Returns: signal of the top sensor, from 0 when nothing is detected to 100 when a hand is very close