Olli Graf
5 months ago
commit
15b89e2431
2 changed files with 49 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||||
|
from machine import Pin |
||||
|
import rp2 |
||||
|
from time import sleep |
||||
|
|
||||
|
@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW) |
||||
|
def blink(): |
||||
|
wrap_target() |
||||
|
set(pins, 1) [31] |
||||
|
nop() [31] |
||||
|
nop() [31] |
||||
|
nop() [31] |
||||
|
set(pins, 0) [31] |
||||
|
nop() [31] |
||||
|
nop() [31] |
||||
|
nop() [31] |
||||
|
wrap() |
||||
|
|
||||
|
led = machine.Pin(25, machine.Pin.OUT) |
||||
|
sm = rp2.StateMachine(0, blink, freq=2000, set_base=led) |
||||
|
|
||||
|
# StateMachine aktivieren |
||||
|
|
||||
|
sm.active(1) |
||||
|
|
||||
|
# Für 3 Sekunden laufen lassen. |
||||
|
sleep(3) |
||||
|
|
||||
|
# deaktivieren |
||||
|
sm.active(0) |
@ -0,0 +1,20 @@ |
|||||
|
from machine import Pin |
||||
|
from utime import sleep |
||||
|
|
||||
|
led = machine.Pin(25, machine.Pin.OUT) |
||||
|
state = False |
||||
|
running = True |
||||
|
|
||||
|
#Endlosschleife |
||||
|
|
||||
|
led.off() |
||||
|
while True: |
||||
|
state = not state # state hin- und herschalten |
||||
|
sleep(1.0) |
||||
|
if state: |
||||
|
print('LED on') |
||||
|
led.on() |
||||
|
# running = False |
||||
|
else: |
||||
|
print('LED off') |
||||
|
led.off() |
Loading…
Reference in new issue