Now did it really...
This commit is contained in:
parent
b5ebf0c2ff
commit
21d9ff8f6d
@ -11,15 +11,15 @@ You should have received a copy of the GNU General Public License along with thi
|
|||||||
|
|
||||||
from ProgramChooser import ProgramChooser
|
from ProgramChooser import ProgramChooser
|
||||||
|
|
||||||
def micronec():
|
def randomblink():
|
||||||
from micronEC import micronec
|
import randomblink
|
||||||
micronec.run()
|
randomblink.run()
|
||||||
def lcd_big_hello():
|
def lcd_big_hello():
|
||||||
from excercise import lcd_big_hello
|
import lcd_big_hello
|
||||||
lcd_big_hello.run()
|
lcd_big_hello.run()
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
"micronEC": micronec,
|
"randomblink": randomblink,
|
||||||
"lcd_big_hello": lcd_big_hello
|
"lcd_big_hello": lcd_big_hello
|
||||||
}
|
}
|
||||||
|
|
48
example/randomblink.py
Normal file
48
example/randomblink.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
"""
|
||||||
|
An example "program" which can be used with the ProgramChooser library, see also main.py
|
||||||
|
Copyright (C) 2024 Benjamin Burkhardt <bluefox@privacynerd.de>
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
# 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()
|
||||||
|
|
Reference in New Issue
Block a user