code.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  # SPDX-License-Identifier: MIT
 3  """
 4  CircuitPython I2S MP3 playback example.
 5  Plays an MP3 once.
 6  
 7  Remove this line and all of the following docstring content before submitting to the Learn repo.
 8  
 9  Update the three I2S pins to match the wiring chosen for the microcontroller. If you are unsure of
10  a proper I2S pin combination, run the pin combination script found here:
11  https://adafru.it/i2s-pin-combo-finder
12  
13  Update the following pin names to a viable pin combination:
14  * BIT_CLOCK_PIN
15  * WORD_SELECT_PIN
16  * DATA_PIN
17  """
18  import board
19  import audiomp3
20  import audiobusio
21  
22  audio = audiobusio.I2SOut(board.BIT_CLOCK_PIN, board.WORD_SELECT_PIN, board.DATA_PIN)
23  
24  with open("slow.mp3", "rb") as mp3_file:
25      mp3 = audiomp3.MP3Decoder(mp3_file)
26  
27      audio.play(mp3)
28      while audio.playing:
29          pass
30  
31  print("Done playing!")