diff options
| author | Dan Halbert <halbert@halwitz.org> | 2018-02-27 22:03:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-27 22:03:52 -0500 |
| commit | 568c04e6afa8016062f685b2198c0209f62827f4 (patch) | |
| tree | d07b76119f715add462983b335797adf64b61249 /examples/switch.py | |
| parent | 6a2379fd0bfe10017d8abc5c36ef1d470c0d9b27 (diff) | |
| parent | ea633117d01d94e8d56ed94344e4b3e46b4eef03 (diff) | |
Merge pull request #650 from tannewt/merge_2x3.0.0-alpha.2
Merge in commits from 2.x branch.
Diffstat (limited to 'examples/switch.py')
| -rw-r--r-- | examples/switch.py | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/examples/switch.py b/examples/switch.py deleted file mode 100644 index 0efaf2267..000000000 --- a/examples/switch.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -switch.py -========= - -Light up some leds when the USR switch on the pyboard is pressed. - -Example Usage:: - - Micro Python v1.0.1 on 2014-05-12; PYBv1.0 with STM32F405RG - Type "help()" for more information. - >>> import switch - >>> switch.run_loop() - Loop started. - Press Ctrl+C to break out of the loop. - -""" - -import pyb - -switch = pyb.Switch() -red_led = pyb.LED(1) -green_led = pyb.LED(2) -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. - - :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.') - 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. - break - -if __name__ == '__main__': - run_loop() |
