let DSP = 0 let FRQ = 0 let BTN = 0 input.onButtonPressed(Button.A, function () { BTN = 1 }) input.onButtonPressed(Button.B, function () { BTN = 0 music.rest(music.beat(BeatFraction.Whole)) }) function F2A() { FRQ = pins.map( pins.analogReadPin(AnalogPin.P1), 0, 1023, 400, 1200 ) music.ringTone(FRQ) DSP = Math.trunc(FRQ / 100) basic.showNumber(DSP) } BTN = 0 FRQ = 0 F2A() basic.forever(function () { if (BTN == 1) { F2A() } else { music.ringTone(FRQ) basic.showString("F2A") } })