Skip to content

Instantly share code, notes, and snippets.

@dglaude
Created February 25, 2021 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dglaude/7ce0a284e25015320712dbf5baf2ffc5 to your computer and use it in GitHub Desktop.
Save dglaude/7ce0a284e25015320712dbf5baf2ffc5 to your computer and use it in GitHub Desktop.
I2S RP2040 playing 10 times in loop.
import board
import audiocore
import audiobusio
import time
print("Playing 10 times StreetChicken.wav")
f = open("StreetChicken.wav", "rb")
wav = audiocore.WaveFile(f)
i2s = audiobusio.I2SOut(board.GP27, board.GP28, board.GP26)
for i in range(10):
start=time.monotonic()
i2s.play(wav)
while i2s.playing:
pass
stop = time.monotonic()
print("Total lenght = ", stop, "-", start, "=", stop-start)
#GPIO26 to DIN (serial data)
#GPIO27 is connected to the BCK input (bit clock)
#GPIO28 to LRCK (left or right clock)
#class audiobusio.I2SOut(
# bit_clock: microcontroller.Pin,
# word_select: microcontroller.Pin,
# data: microcontroller.Pin,
# *,
# left_justified: bool)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment