Touch Sensor

With QikEasy EV3 Spike Prime Adapter, you can use your existing EV3 Touch Sensor as an additional push button control on Spike Prime or Robot Inventor kit.

Indispensable Push  Button functionality

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.

How to use it on Spike Prime or Robot Inventor?

  1. Connect your EV3 Touch Sensor to the bigger socket on the QikEasy Adapter.
  2. Connect one end of a Spike Prime cable to the smaller socket on the QikEasy Adapter.
  3. Connect the other end of the Spike Prime cable to one of the 6 ports on the Spike Prime (or Robot Inventor) hub.
  4. Your Spike Prime or Mindstorms Hub will detect your EV3 Touch Sensor through the QikEasy Adapter as a Spike Prime Force Sensor.

 

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.

 

Program in Word Blocks:

 

Using Word Blocks, there are several ways to detect the button presses or button releases.  Below, we show 4 different ways for performing such detections.  They are all valid ways to do the same thing.


Program with Python:

 

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()