Force Sensor
A spring-loaded button sensor: a switch (pressed/released) and a force gauge (0-10 newtons) in one.
What it measures
| Mode | Reading |
|---|---|
| pressed | true / false |
| hard-pressed | true / false (above roughly 5 N) |
| force | 0-10 N, ~0.1 N resolution |
Word Blocks
<force sensor [E] [pressed]>
<force sensor [E] [hard-pressed]>
(force sensor [E] pressure %)
wait until <force sensor [E] pressed>Example 1: press to launch
A "soft start button" for practice - the robot waits for a tap:
when program starts
set movement motors [A+E]
wait until <force sensor [E] pressed>
wait until <not <force sensor [E] pressed>> ← wait for release, so the robot doesn't launch into your hand
move [forward] for [5] rotationsExample 2: wall contact detection
Mount the sensor on the robot's tail; back up into the wall - button pressed means firmly against it:
start moving [backward]
wait until <force sensor [E] pressed>
stop moving
reset yaw angle [0] ← known pose against the wall: recalibrate the gyro while you're herePython
python
import runloop, force_sensor
from hub import port
async def main():
if force_sensor.pressed(port.E):
pass
f = force_sensor.force(port.E) # decinewtons: 0-100 maps to 0-10 N
runloop.run(main())Python returns decinewtons
force() returns 0-100 in decinewtons (1 N = 10 dN). A reading of 35 = 3.5 N.
FLL uses
- Confirming wall squaring: more reliable than "reverse a fixed distance" - contact is proven (see the full wall-squaring recipe in FLL Techniques).
- Debug trigger: tap to run the next test segment without touching the computer.
- Attachment end-stop: stop the arm when it presses the target, preventing overdrive.
Common pitfalls
- The button travel is a few millimeters; mount it so impact aligns with the button axis - glancing hits may not press it.
- It's a contact sensor: it must physically hit. For touch-free tasks use the distance sensor.
Next: Hub Built-in Sensors - the gyro lives there.