Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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