aboutsummaryrefslogtreecommitdiff
path: root/examples/switch.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/switch.py')
-rw-r--r--examples/switch.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/switch.py b/examples/switch.py
index 0efaf2267..c099a3529 100644
--- a/examples/switch.py
+++ b/examples/switch.py
@@ -24,6 +24,7 @@ orange_led = pyb.LED(3)
blue_led = pyb.LED(4)
all_leds = (red_led, green_led, orange_led, blue_led)
+
def run_loop(leds=all_leds):
"""
Start the loop.
@@ -31,15 +32,16 @@ def run_loop(leds=all_leds):
:param `leds`: Which LEDs to light up upon switch press.
:type `leds`: sequence of LED objects
"""
- print('Loop started.\nPress Ctrl+C to break out of the loop.')
+ print("Loop started.\nPress Ctrl+C to break out of the loop.")
while 1:
try:
if switch():
[led.on() for led in leds]
else:
[led.off() for led in leds]
- except OSError: # VCPInterrupt # Ctrl+C in interpreter mode.
+ except OSError: # VCPInterrupt # Ctrl+C in interpreter mode.
break
-if __name__ == '__main__':
+
+if __name__ == "__main__":
run_loop()