Skip to content

Commit 7488a20

Browse files
authored
Add led_off function
* Add led_off function * Changed set_value() to led_off()
1 parent e79121f commit 7488a20

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

neopia/neosoco.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,24 @@ def led_on(self, port: str, brightness: str):
426426
else:
427427
raise TypeError
428428

429+
def led_off(self, port: str):
430+
if isinstance(port, str):
431+
if port.lower() =='out1':
432+
self.write(Neosoco.OUTPUT_1, 0)
433+
elif port.lower() =='out2':
434+
self.write(Neosoco.OUTPUT_2, 0)
435+
elif port.lower() =='out3':
436+
self.write(Neosoco.OUTPUT_3, 0)
437+
elif port.lower() =='all':
438+
self.write(Neosoco.OUTPUT_1, 0)
439+
self.write(Neosoco.OUTPUT_2, 0)
440+
self.write(Neosoco.OUTPUT_3, 0)
441+
else:
442+
Util.print_error('Wrong value of port')
443+
raise ValueError
444+
else:
445+
raise TypeError
446+
429447
def motor_move(self, direction: str):
430448
if isinstance(direction, str):
431449
if direction.lower() =='forward':

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# if n.get_value('in1') < 10:
1616
# n.led_on('out1', '100')
1717
# else:
18-
# n.set_value('out1', 0)
18+
# n.led_off('out1')
1919

2020
# case4) Move forth and back during 1s and stop
2121
# n.motor_move('forward')

0 commit comments

Comments
 (0)