diff --git a/Sparkle_Motion_Examples/Arduino_I2S_SparkleMotion/.feather_esp32_v2.test.only b/Sparkle_Motion_Examples/Arduino_I2S_SparkleMotion/.feather_esp32_v2.test.only new file mode 100644 index 000000000..e69de29bb diff --git a/Sparkle_Motion_Examples/Arduino_I2S_SparkleMotion/Arduino_I2S_SparkleMotion.ino b/Sparkle_Motion_Examples/Arduino_I2S_SparkleMotion/Arduino_I2S_SparkleMotion.ino new file mode 100644 index 000000000..2b7a4c791 --- /dev/null +++ b/Sparkle_Motion_Examples/Arduino_I2S_SparkleMotion/Arduino_I2S_SparkleMotion.ino @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2025 Limor Fried for Adafruit Industries +// +// SPDX-License-Identifier: MIT + +#include +#include "ESP_I2S.h" + +// I2S pin definitions for Sparklemotion +const uint8_t I2S_SCK = 26; // BCLK +const uint8_t I2S_WS = 33; // LRCLK +const uint8_t I2S_DIN = 25; // DATA_IN + +// Create I2S instance +I2SClass i2s; + +void setup() { + // Fast serial for plotting + Serial.begin(500000); + + // Initialize I2S + i2s.setPins(I2S_SCK, I2S_WS, -1, I2S_DIN); + if (!i2s.begin(I2S_MODE_STD, 44100, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO, I2S_STD_SLOT_LEFT)) { + Serial.println("Failed to initialize I2S bus!"); + return; + } + + Serial.println("I2S Mic Plotter Ready"); +} + +void loop() { + static uint32_t lastPlot = 0; + + // Get a sample + int32_t sample = i2s.read(); + + // Only plot every 1ms (1000 samples/sec is plenty for visualization) + if (millis() - lastPlot >= 1) { + if (sample >= 0) { // Valid sample + // Plot both raw and absolute values + Serial.printf("%d,%d\n", (int16_t)sample, abs((int16_t)sample)); + } + lastPlot = millis(); + } +} diff --git a/Sparkle_Motion_Examples/Arduino_Sparkle_Motion_Multi_NeoPixels/Arduino_Sparkle_Motion_Multi_NeoPixels.ino b/Sparkle_Motion_Examples/Arduino_Sparkle_Motion_Multi_NeoPixels/Arduino_Sparkle_Motion_Multi_NeoPixels.ino new file mode 100644 index 000000000..af8651820 --- /dev/null +++ b/Sparkle_Motion_Examples/Arduino_Sparkle_Motion_Multi_NeoPixels/Arduino_Sparkle_Motion_Multi_NeoPixels.ino @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries +// +// SPDX-License-Identifier: MIT + +#include + +#define BLOCK_1 21 +#define BLOCK_2 22 +#define NUM_PIXELS 8 + +Adafruit_NeoPixel STRIP_1(NUM_PIXELS, BLOCK_1, NEO_GRB + NEO_KHZ800); +Adafruit_NeoPixel STRIP_2(NUM_PIXELS, BLOCK_2, NEO_GRB + NEO_KHZ800); + +void setup() { + STRIP_1.begin(); + STRIP_2.begin(); + STRIP_1.setBrightness(25); + STRIP_2.setBrightness(50); +} + +uint16_t pixelHue_1 = 0; +uint16_t pixelHue_2 = 256; + +void loop() { + pixelHue_1 += 256; + for(int i=0; i-1; i--) { + int hue_2 = pixelHue_2 + (i * 65536L / STRIP_2.numPixels()); + STRIP_2.setPixelColor(i, STRIP_2.gamma32(STRIP_2.ColorHSV(hue_2))); + } + STRIP_2.show(); + + delay(10); + +} diff --git a/Sparkle_Motion_Examples/CircuitPython_Sparkle_Motion_Neopixel_Animation/code.py b/Sparkle_Motion_Examples/CircuitPython_Sparkle_Motion_Neopixel_Animation/code.py new file mode 100644 index 000000000..e08c423bf --- /dev/null +++ b/Sparkle_Motion_Examples/CircuitPython_Sparkle_Motion_Neopixel_Animation/code.py @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries +# +# SPDX-License-Identifier: MIT +""" +Example illustrating two different LED Animations running on +Neopixels connected to 2 of the main outputs of the Sparkle Motion +""" +import board +import neopixel + +from adafruit_led_animation.animation.comet import Comet +from adafruit_led_animation.animation.rainbow import Rainbow +from adafruit_led_animation.color import GREEN + +strip1_pixel_pin = board.D21 +strip2_pixel_pin = board.D22 + +pixel_count = 8 + +strip1_pixels = neopixel.NeoPixel( + strip1_pixel_pin, pixel_count, brightness=0.1, auto_write=False +) +strip2_pixels = neopixel.NeoPixel( + strip2_pixel_pin, pixel_count, brightness=0.1, auto_write=False +) + +comet = Comet(strip1_pixels, speed=0.05, color=GREEN, tail_length=3, bounce=True) +rainbow = Rainbow(strip2_pixels, speed=0.05, period=3) + +while True: + comet.animate() + rainbow.animate()