Skip to content

Commit da1ca86

Browse files
committed
update force example
1 parent 0afe764 commit da1ca86

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

docs/buildhat/force.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
from buildhat import Motor, ForceSensor
33

44
motor = Motor('A')
5-
button = ForceSensor('D')
5+
button = ForceSensor('D', threshold_force=1)
66

7-
print("Waiting for button to be pressed and released")
7+
print("Waiting for button to be pressed fully and released")
88

9-
button.wait_until_pressed()
10-
button.wait_until_released()
9+
button.wait_until_pressed(100)
10+
button.wait_until_released(0)
1111

1212
motor.run_for_rotations(1)
1313

@@ -16,16 +16,12 @@
1616
button.wait_until_pressed()
1717
motor.run_for_rotations(2)
1818

19-
def handle_force(force, pressed):
20-
print("Force", force, pressed)
21-
22-
def handle_pressed():
23-
print("pressed")
19+
def handle_pressed(force):
20+
print("pressed", force)
2421

25-
def handle_released():
26-
print("released")
22+
def handle_released(force):
23+
print("released", force)
2724

28-
button.when_force = handle_force
2925
button.when_pressed = handle_pressed
3026
button.when_released = handle_released
3127
pause()

0 commit comments

Comments
 (0)