File tree 2 files changed +22
-7
lines changed
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):
435
435
self .write (Neosoco .LEFT_MOTOR , self ._MOTOR_DIR ['backward' ]+ self ._MOTOR_PERCENT_CVT ['60' ])
436
436
self .write (Neosoco .RIGHT_MOTOR , self ._MOTOR_DIR ['backward' ]+ self ._MOTOR_PERCENT_CVT ['60' ])
437
437
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' ] )
439
439
self .write (Neosoco .RIGHT_MOTOR , self ._MOTOR_DIR ['forward' ]+ self ._MOTOR_PERCENT_CVT ['60' ])
440
440
elif direction .lower () == 'right' :
441
441
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' ] )
443
443
elif direction .lower () == 'stop' :
444
444
self .write (Neosoco .LEFT_MOTOR , 0 )
445
445
self .write (Neosoco .RIGHT_MOTOR , 0 )
Original file line number Diff line number Diff line change 18
18
# n.set_value('out1', 0)
19
19
20
20
# 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