from board import LED
from machine import Pin, PWM, Timer
from time import sleep
import math

#led = Pin(LED, mode=Pin.OUT)
led_ext = Pin(27, mode=Pin.OUT)

brightness = 0
bach = [131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247, 262, 277, 294, 311, 330, 349, 370, 370, 392, 415, 440, 466, 494, 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976, 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951, 4186, 4435, 4699, 4978]

L1 = PWM(led_ext,freq=200,duty=0,timer=0)


def tcb(timer):
    global brightness

    if brightness<len(bach):
        brightness += 1
    else:
        brightness = 0

    print(bach[brightness])
    L1.freq(bach[brightness])
    L1.duty(50)

t1 = Timer(1)
t1.init(period=250, mode=t1.PERIODIC, callback=tcb)



#led_ext = Pin(LED, mode=Pin.OUT)