In many robotic projects, you need more than one push button for action triggering. With a QikEasy Adapter, it is peace of mind to know that you have such extra push button device at your disposal any time in your toolkit.
The converted EV3 Touch Sensor emulates and works exactly the same as a Spike Prime Force Sensor. You would program it in exactly the same way. However, because EV3 Touch Sensor can only sense ON and OFF states, it would not give you “force” information. When the sensor is pushed, the emulated Force Sensor would sense 100% or 10 Newtons. When the sensor is released, the emulated Force Sensor would sense 0% or 0 Newton.
Similar to programming Word Block, there are 2 ways to detect EV3 Touch Sensor button presses and releases. Below, we show the 2 ways to perform this detection in Python. Both ways are valid and you may use either method to perform the detection.
Method 1:
# On Spike Prime, use the following as first two lines instead: # from spike import PrimeHub, ForceSensor # hub = PrimeHub() from mindstorms import MSHub, ForceSensor hub = MSHub() forceSensor = ForceSensor('E') # Forever loop that draws happy face when force button is pressed while 1: if forceSensor.is_pressed(): hub.light_matrix.show_image('HAPPY') else: hub.light_matrix.off()
Method 2:
# On Spike Prime, use the following as first two lines instead: # from spike import PrimeHub, ForceSensor # hub = PrimeHub() from mindstorms import MSHub, ForceSensor hub = MSHub() forceSensor = ForceSensor('E') # Forever loop that draws happy face when force button is pressed while 1: if forceSensor.get_force_newton() == 10: hub.light_matrix.show_image('HAPPY') else: hub.light_matrix.off()