File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -435,11 +435,11 @@ def motor_move(self, direction: str):
435435 self .write (Neosoco .LEFT_MOTOR , self ._MOTOR_DIR ['backward' ]+ self ._MOTOR_PERCENT_CVT ['60' ])
436436 self .write (Neosoco .RIGHT_MOTOR , self ._MOTOR_DIR ['backward' ]+ self ._MOTOR_PERCENT_CVT ['60' ])
437437 elif direction .lower () == 'left' :
438- self .write (Neosoco .LEFT_MOTOR , 0 )
438+ self .write (Neosoco .LEFT_MOTOR , self . _MOTOR_DIR [ 'backward' ] + self . _MOTOR_PERCENT_CVT [ '60' ] )
439439 self .write (Neosoco .RIGHT_MOTOR , self ._MOTOR_DIR ['forward' ]+ self ._MOTOR_PERCENT_CVT ['60' ])
440440 elif direction .lower () == 'right' :
441441 self .write (Neosoco .LEFT_MOTOR , self ._MOTOR_DIR ['forward' ]+ self ._MOTOR_PERCENT_CVT ['60' ])
442- self .write (Neosoco .RIGHT_MOTOR , 0 )
442+ self .write (Neosoco .RIGHT_MOTOR , self . _MOTOR_DIR [ 'backward' ] + self . _MOTOR_PERCENT_CVT [ '60' ] )
443443 elif direction .lower () == 'stop' :
444444 self .write (Neosoco .LEFT_MOTOR , 0 )
445445 self .write (Neosoco .RIGHT_MOTOR , 0 )
Original file line number Diff line number Diff line change 1818# n.set_value('out1', 0)
1919
2020# case4) Move forth and back during 1s and stop
21- n .motor_move ('forward' )
22- wait (500 )
23- n .motor_move ('backward' )
24- wait (500 )
25- n .motor_move ('stop' )
21+ # n.motor_move('forward')
22+ # wait(500)
23+ # n.motor_move('backward')
24+ # wait(500)
25+ # n.motor_move('stop')
26+
27+ # case5) Moving cotrol by direction keys on the keyboard
28+ while True :
29+ key = Keyboard .read ()
30+
31+ if key == Keyboard .UP :
32+ n .motor_move ('forward' )
33+ elif key == Keyboard .DOWN :
34+ n .motor_move ('backward' )
35+ elif key == Keyboard .LEFT :
36+ n .motor_move ('left' )
37+ elif key == Keyboard .RIGHT :
38+ n .motor_move ('right' )
39+ elif key == ' ' :
40+ n .motor_move ('stop' )
You can’t perform that action at this time.
0 commit comments