Olli Graf
2 months ago
commit
b43fbd9e11
2 changed files with 42 additions and 0 deletions
@ -0,0 +1,42 @@ |
|||
#encoding: utf-8 |
|||
import machine |
|||
import network |
|||
import socket |
|||
import rp2 |
|||
from time import sleep_ms,sleep |
|||
from machine import Pin,PWM |
|||
|
|||
led = Pin(15, Pin.OUT) |
|||
pwm = PWM(Pin(15)) |
|||
duty_step = 129 # Schrittweite für den Tastgrad |
|||
|
|||
|
|||
|
|||
# Frequenz in Hertz (Hz) einstellen |
|||
# Bei höhren Werten als 100 wird der Piezo Speaker "basslastiger" und die LED |
|||
# erreicht nicht ihre max. Helligkeit. |
|||
# Bei niedrigeren flackert die LED |
|||
pwm.freq(100) |
|||
|
|||
# initialer Tastgrad (Duty Cycle) |
|||
pwm.duty_u16(0) |
|||
|
|||
try: |
|||
while True: |
|||
# linear ansteigender Tastgrad |
|||
for duty_cycle in range(0, 65536, duty_step): |
|||
pwm.duty_u16(duty_cycle) |
|||
sleep_ms(10) |
|||
|
|||
sleep(2) |
|||
|
|||
# Linear absteigender Tastgrad |
|||
for duty_cycle in range(65536, 0, -duty_step): |
|||
pwm.duty_u16(duty_cycle) |
|||
sleep_ms(10) |
|||
sleep(2) |
|||
finally: |
|||
print('finally') |
|||
pwm.duty_u16(0) |
|||
pwm.deinit() |
|||
led.off() |
After Width: | Height: | Size: 667 KiB |
Loading…
Reference in new issue