Added comments, frequency variable

This commit is contained in:
Kattni Rembor 2018-07-10 16:00:50 -04:00
parent 7123fb9da4
commit b8ef37f0ad
2 changed files with 5 additions and 1 deletions

View file

@ -9,7 +9,8 @@ button = digitalio.DigitalInOut(board.A1)
button.switch_to_input(pull=digitalio.Pull.UP)
tone_volume = 0.1 # Increase this to increase the volume of the tone.
length = 8000 // 440
frequency = 440 # Set this to the Hz of the tone you want to generate.
length = 8000 // frequency
sine_wave = array.array("H", [0] * length)
for i in range(length):
sine_wave[i] = int((1 + math.sin(math.pi * 2 * i / 18)) * tone_volume * (2 ** 15))

View file

@ -12,9 +12,12 @@ audio = audioio.AudioOut(board.A0)
while True:
audio.play(wave)
# This allows you to do other things while the audio plays!
t = time.monotonic()
while time.monotonic() - t < 6:
pass
audio.pause()
print("Waiting for button press to continue!")
while button.value: