Печать

В этом примере показано как плавно управлять яркостью светодиода на Raspberry Pi Pico. fading.py распространяется в надежде, что это будет полезно, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ, даже без подразумеваемой гарантии ТОВАРНОЙ или иной ПРИГОДНОСТИ.

# Fading
# This example shows how to smoothly control the LED brightness on a Raspberry Pi Pico
#
# Created on June 12, 2021.
# Author: Sysoev E.
# Changed on June 13, 2021
# Diorditsa A.

# fading.py is distributed in the hope that it will be useful, but
# WITHOUT WARRANTY OF ANY KIND; not even an implied warranty
# MARKETABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See. See the GNU General Public License for more information.
# You can get a copy of the GNU General Public License
# by link http://www.gnu.org/licenses/


from machine import Pin, PWM
from utime import sleep

pwm = PWM(Pin(25))
pwm.freq(200)

while True:
    for i in range(-250, 250):
        pwm.duty_u16(i**2)
        sleep(0.01)