diff --git a/examples/lcd_big_hello.py b/example/lcd_big_hello.py similarity index 100% rename from examples/lcd_big_hello.py rename to example/lcd_big_hello.py diff --git a/examples/main.py b/example/main.py similarity index 87% rename from examples/main.py rename to example/main.py index a315ea3..ae68a4f 100644 --- a/examples/main.py +++ b/example/main.py @@ -11,15 +11,15 @@ You should have received a copy of the GNU General Public License along with thi from ProgramChooser import ProgramChooser -def micronec(): - from micronEC import micronec - micronec.run() +def randomblink(): + import randomblink + randomblink.run() def lcd_big_hello(): - from excercise import lcd_big_hello + import lcd_big_hello lcd_big_hello.run() programs = { - "micronEC": micronec, + "randomblink": randomblink, "lcd_big_hello": lcd_big_hello } diff --git a/example/randomblink.py b/example/randomblink.py new file mode 100644 index 0000000..c9d360a --- /dev/null +++ b/example/randomblink.py @@ -0,0 +1,48 @@ +""" +An example "program" which can be used with the ProgramChooser library, see also main.py +Copyright (C) 2024 Benjamin Burkhardt + +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program. If not, see . +""" + +""" +# Feature: blink pico's onboard led (GPIO25) randomly +""" + +from machine import Pin +from time import sleep +import random + +def run(): + # Initialisierung von GPIO25 als Ausgang + led_onboard = Pin(25, Pin.OUT) + pause_counter = 0 + counter = 0 + + # repeat for some time (as it's randomly you don't really now) + # approx ~30s + while counter < 30: + # turn LED on + led_onboard.on() + # wait a short time (80ms) + sleep(0.08) + # turn LED off + led_onboard.off() + # wait a shorter time (20ms) + sleep(0.02) + pause_counter += 1 + + # make a pause (1s) randomly + if pause_counter > random.randint(6,20): + sleep(1) + + print(counter) + counter += 1 + +if __name__ == "__main__": + run() +