diff --git a/Feather_RP2350_Examples/CircuitPython_Digital_Input/code.py b/Feather_RP2350_Examples/CircuitPython_Digital_Input/code.py new file mode 100644 index 000000000..d51f7cd94 --- /dev/null +++ b/Feather_RP2350_Examples/CircuitPython_Digital_Input/code.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries +# SPDX-License-Identifier: MIT +""" +CircuitPython Digital Input Example - Blinking an LED using a button switch. +""" +import board +import digitalio + +led = digitalio.DigitalInOut(board.LED) +led.direction = digitalio.Direction.OUTPUT + +button = digitalio.DigitalInOut(board.D5) +button.switch_to_input(pull=digitalio.Pull.UP) + +while True: + if not button.value: + led.value = True + else: + led.value = False diff --git a/Feather_RP2350_Examples/CircuitPython_I2S_Tone/code.py b/Feather_RP2350_Examples/CircuitPython_I2S_Tone/code.py new file mode 100644 index 000000000..2651b0644 --- /dev/null +++ b/Feather_RP2350_Examples/CircuitPython_I2S_Tone/code.py @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries +# SPDX-License-Identifier: MIT +""" +CircuitPython I2S Tone playback example. +Plays a tone for one second on, one +second off, in a loop. +""" +import time +import array +import math +import audiocore +import board +import audiobusio + +audio = audiobusio.I2SOut(board.D6, board.D5, board.D9) + +tone_volume = 0.1 # Increase this to increase the volume of the tone. +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((math.sin(math.pi * 2 * i / length)) * tone_volume * (2 ** 15 - 1)) +sine_wave_sample = audiocore.RawSample(sine_wave) + +while True: + audio.play(sine_wave_sample, loop=True) + time.sleep(1) + audio.stop() + time.sleep(1) diff --git a/Feather_RP2350_Examples/CircuitPython_I2S_Wav/StreetChicken.wav b/Feather_RP2350_Examples/CircuitPython_I2S_Wav/StreetChicken.wav new file mode 100644 index 000000000..55d4eb0f2 Binary files /dev/null and b/Feather_RP2350_Examples/CircuitPython_I2S_Wav/StreetChicken.wav differ diff --git a/Feather_RP2350_Examples/CircuitPython_I2S_Wav/code.py b/Feather_RP2350_Examples/CircuitPython_I2S_Wav/code.py new file mode 100644 index 000000000..c7f0b55a9 --- /dev/null +++ b/Feather_RP2350_Examples/CircuitPython_I2S_Wav/code.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries +# SPDX-License-Identifier: MIT +""" +CircuitPython I2S WAV file playback. +Plays a WAV file once. +""" +import audiocore +import board +import audiobusio + +audio = audiobusio.I2SOut(board.D6, board.D5, board.D9) + +with open("StreetChicken.wav", "rb") as wave_file: + wav = audiocore.WaveFile(wave_file) + + print("Playing wav file!") + audio.play(wav) + while audio.playing: + pass + +print("Done!") diff --git a/Feather_RP2350_Examples/CircuitPython_PWM_mp3/code.py b/Feather_RP2350_Examples/CircuitPython_PWM_mp3/code.py new file mode 100644 index 000000000..db70b9a6c --- /dev/null +++ b/Feather_RP2350_Examples/CircuitPython_PWM_mp3/code.py @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries +# SPDX-License-Identifier: MIT +""" +CircuitPython single MP3 playback example. +Plays a single MP3 once. +""" +import board +import audiomp3 +import audiopwmio + +audio = audiopwmio.PWMAudioOut(board.A0) + +with open("slow.mp3", "rb") as mp3_file: + decoder = audiomp3.MP3Decoder(mp3_file) + + audio.play(decoder) + while audio.playing: + pass + +print("Done playing!") diff --git a/Feather_RP2350_Examples/CircuitPython_PWM_mp3/slow.mp3 b/Feather_RP2350_Examples/CircuitPython_PWM_mp3/slow.mp3 new file mode 100644 index 000000000..39ceecdf6 Binary files /dev/null and b/Feather_RP2350_Examples/CircuitPython_PWM_mp3/slow.mp3 differ diff --git a/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/code.py b/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/code.py new file mode 100644 index 000000000..fc60fbc45 --- /dev/null +++ b/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/code.py @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries +# SPDX-License-Identifier: MIT +""" +CircuitPython multiple MP3 playback example. +Plays two MP3 files consecutively, once time each. +""" + +import board +import audiomp3 +import audiopwmio + +audio = audiopwmio.PWMAudioOut(board.A0) + +mp3files = ["slow.mp3", "happy.mp3"] + +with open(mp3files[0], "rb") as mp3: + decoder = audiomp3.MP3Decoder(mp3) + + for filename in mp3files: + with open(filename, "rb") as decoder.file: + audio.play(decoder) + print("Playing:", filename) + while audio.playing: + pass + +print("Done playing!") diff --git a/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/happy.mp3 b/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/happy.mp3 new file mode 100644 index 000000000..58fd59724 Binary files /dev/null and b/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/happy.mp3 differ diff --git a/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/slow.mp3 b/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/slow.mp3 new file mode 100644 index 000000000..39ceecdf6 Binary files /dev/null and b/Feather_RP2350_Examples/CircuitPython_PWM_multiMP3/slow.mp3 differ