File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -333,6 +333,24 @@ def _notify_sensory_device_data_changed(self):
333
333
def _notify_motoring_device_data_changed (self ):
334
334
self ._roboid ._notify_motoring_device_data_changed ()
335
335
336
+ def set_value (self , port : str , value : int ):
337
+ if isinstance (port , str ) and isinstance (value , int ):
338
+ if port .lower () == 'out1' :
339
+ self .write (Neosoco .OUTPUT_1 , Util .round (value ))
340
+ elif port .lower () == 'out2' :
341
+ self .write (Neosoco .OUTPUT_2 , Util .round (value ))
342
+ elif port .lower () == 'out3' :
343
+ self .write (Neosoco .OUTPUT_3 , Util .round (value ))
344
+ elif port .lower () == 'all' :
345
+ self .write (Neosoco .OUTPUT_1 , Util .round (value ))
346
+ self .write (Neosoco .OUTPUT_2 , Util .round (value ))
347
+ self .write (Neosoco .OUTPUT_3 , Util .round (value ))
348
+ else :
349
+ Util .print_error ('Wrong value of port' )
350
+ raise ValueError
351
+ else :
352
+ raise TypeError
353
+
336
354
def get_value (self , port : str ):
337
355
if isinstance (port , str ):
338
356
if port .lower () == 'in1' :
Original file line number Diff line number Diff line change 3
3
n = Neosoco ()
4
4
5
5
# case1) Turn on LED with 100% brightness during 1s
6
- n .led_on ("out1" , '100' )
6
+ # n.led_on("out1", '100')
7
+ # wait(1000)
8
+
9
+ n .set_value ("out1" , 255 )
7
10
wait (1000 )
8
11
9
12
# case2) Turn on LED when the distance is under 10cm
You can’t perform that action at this time.
0 commit comments