import pyb, array # Create the DAC that drives our audio. # DAC(1) drives pin X5; DAC(2) drives pin X6. # Bits is 8 or 12. dac = pyb.DAC (1, buffering=False) # 'Freq' is in cycles/second; middle C on a piano is 261Hz. # 'Volume' is a number from 0-10. # The note we play is a sawtooth. def play_note (freq, volume): global buf assert volume>=0 and volume<=10, "Illegal volume setting" Vmax = int(volume*255/10) buf = array.array ('B', range(Vmax)) dac.write_timed (buf, int(freq*Vmax), mode=pyb.DAC.CIRCULAR) ############################ ### Your code starts here ############################ play_note (1000, 3); pyb.delay(500) play_note (1000*1.0595, 3); pyb.delay(500) play_note (0,0)