File tree 1 file changed +8
-12
lines changed
1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change 2
2
from buildhat import Motor , ForceSensor
3
3
4
4
motor = Motor ('A' )
5
- button = ForceSensor ('D' )
5
+ button = ForceSensor ('D' , threshold_force = 1 )
6
6
7
- print ("Waiting for button to be pressed and released" )
7
+ print ("Waiting for button to be pressed fully and released" )
8
8
9
- button .wait_until_pressed ()
10
- button .wait_until_released ()
9
+ button .wait_until_pressed (100 )
10
+ button .wait_until_released (0 )
11
11
12
12
motor .run_for_rotations (1 )
13
13
16
16
button .wait_until_pressed ()
17
17
motor .run_for_rotations (2 )
18
18
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 )
24
21
25
- def handle_released ():
26
- print ("released" )
22
+ def handle_released (force ):
23
+ print ("released" , force )
27
24
28
- button .when_force = handle_force
29
25
button .when_pressed = handle_pressed
30
26
button .when_released = handle_released
31
27
pause ()
You can’t perform that action at this time.
0 commit comments