from machine import Pin,PWM,SoftI2C
from ssd1306 import SSD1306_I2C
import time
i2c = SoftI2C(sda = Pin(27),scl = Pin(26))
oled = SSD1306_I2C(128,64,i2c,addr = 0x3c)


while 1:
    def myBeep(music_value,freq_value):
        Beep = PWM(Pin(2),freq = 1,duty = 128)
        oled.fill(0)
        oled.text(str(music_value),64,32)
        oled.show()
        Beep.freq(music_value)
        time.sleep(1)
    myBeep(1,262)
    myBeep(2,294)
    myBeep(3,330)
    myBeep(4,350)
    myBeep(5,393)
    myBeep(6,441)
    myBeep(7,495)

    '''Beep = PWM(Pin(2),freq = 1,duty = 128)
    oled.fill(0)
    oled.text("1",64,32)
    oled.show()
    Beep.freq(262)
    time.sleep(1)
    Beep.duty(0)
    time.sleep_ms(200)

    Beep = PWM(Pin(2),freq = 1,duty = 128)
    oled.fill(0)
    oled.text("2",64,32)
    oled.show()
    Beep.freq(294)
    time.sleep(1)
    Beep.duty(0)
    time.sleep_ms(200)

    Beep = PWM(Pin(2),freq = 1,duty = 128)
    oled.fill(0)
    oled.text("3",64,32)
    oled.show()
    Beep.freq(330)
    time.sleep(1)
    Beep.duty(0)
    time.sleep_ms(200)

    Beep = PWM(Pin(2),freq = 1,duty = 128)
    oled.fill(0)
    oled.text("4",64,32)
    oled.show()
    Beep.freq(350)
    time.sleep(1)
    Beep.duty(0)
    time.sleep_ms(200)

    Beep = PWM(Pin(2),freq = 1,duty = 128)
    oled.fill(0)
    oled.text("5",64,32)
    oled.show()
    Beep.freq(393)
    time.sleep(1)
    Beep.duty(0)
    time.sleep_ms(200)

    Beep = PWM(Pin(2),freq = 1,duty = 128)
    oled.fill(0)
    oled.text("6",64,32)
    oled.show()
    Beep.freq(441)
    time.sleep(1)
    Beep.duty(0)
    time.sleep_ms(200)

    Beep = PWM(Pin(2),freq = 1,duty = 128)
    oled.fill(0)
    oled.text("7",64,32)
    oled.show()
    Beep.freq(495)
    time.sleep(1)
    Beep.duty(0)
    time.sleep_ms(200)'''































oled.fill(0)
oled.text("1",64,32)
oled.show()
                    






























'''Beep = PWM(Pin(2),freq = 1,duty = 128)
for i in range(3):

    Beep.freq(300)
    time.sleep(1)
    Beep.freq(800)
    time.sleep(1)
Beep.deinit()'''