package main import ( "time" ) func Music() { display.FillScreen(colorWhite) writeLine("Music", colorCyan, displayWidth/2, displayHeight/3, displayHeight, true) writeLine("Press any key", colorRed, displayWidth/2, 2*displayHeight/3, displayHeight, true) for { getInput() if buttonsState[buttonBack] { break } if buttonsState[buttonStart] { tone(5274) } if buttonsState[buttonA] { tone(1046) } if buttonsState[buttonB] { tone(1975) } if buttonsState[buttonLeft] { tone(329) } if buttonsState[buttonRight] { tone(739) } if buttonsState[buttonUp] { tone(369) } if buttonsState[buttonDown] { tone(523) } } } func tone(tone int) { for i := 0; i < 10; i++ { bzrPin.High() time.Sleep(time.Duration(tone) * time.Microsecond) bzrPin.Low() time.Sleep(time.Duration(tone) * time.Microsecond) } }