The following is test code for a string of APA102 LED. we hope to get a card back with the SMD LEDs mounted to a card. it is a clock with 120 on the outer ring and 96 on the inner ring. The second hand is a set of 6 LEDs illuminated in a SIN wave distribution that moves at 10Hz update rate around the otter ring. I would like to use the stereo audio out put to make it into an alarm clock.
Can the audio output function of the T3.6 work with updating at 10Hz? or would I need to pause the clock when the audio output is active?
#include <Adafruit_DotStar.h>
// Because conditional #includes don't work w/Arduino sketches...
#include <SPI.h>
#define NUMPIXELS 214 // Number of LEDs in strip
// Here's how to control the LEDs from any two pins:
#define DATAPIN 4 // key top pin
#define CLOCKPIN 5 // mid pin
Adafruit_DotStar strip = Adafruit_DotStar(
NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
int SecSteps=0;
int TimeIndex=-2;
void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
strip.begin(); // Initialize pins for output
strip.show(); // Turn all LEDs off ASAP
}
int StartUpA[]={ 0x010000, 0x010000, 0x010000, 0x030000, 0x060000, };
int StartUpB[]={ 0x090000, 0x0D0000, 0x110000, 0x160000, 0x1A0000,};
int EndUpA[]={ 0x1F0000, 0x250000, 0x290000, 0x2E0000, 0x320000, };
int EndUpB[]={ 0x360000, 0x390000, 0x3C0000, 0x3E0000, 0x3F0000,};
int StartDownA[]={ 0x400000, 0x3F0000, 0x3E0000, 0x3C0000, 0x390000, };
int StartDownB[]={ 0x360000, 0x320000, 0x2E0000, 0x290000, 0x250000,};
int EndDownA[]={ 0x200000, 0x1A0000, 0x160000, 0x110000, 0x0D0000, };
int EndDownB[]={ 0x090000, 0x060000, 0x030000, 0x010000, 0x010000,};
void loop() {
for(int i=-7;i<15; i++){ strip.setPixelColor(i, 0x010000);} // set slight green
if(TimeIndex>12){TimeIndex=-4;}
SecSteps=0;
while(SecSteps<=4)
{
strip.setPixelColor(TimeIndex+4,StartUpA[SecSteps]); //g-r-b
strip.setPixelColor(TimeIndex+3,StartUpB[SecSteps]);//StartUp[SecSteps]);
strip.setPixelColor(TimeIndex+2,EndUpA[SecSteps]); //StartUp[SecSteps]);
strip.setPixelColor(TimeIndex+1,EndUpB[SecSteps]);
strip.setPixelColor(TimeIndex+0,StartDownA[SecSteps]); //g-r-b
strip.setPixelColor(TimeIndex-1,StartDownB[SecSteps]);//StartUp[SecSteps]);
strip.setPixelColor(TimeIndex-2,EndDownA[SecSteps]); //StartUp[SecSteps]);
strip.setPixelColor(TimeIndex-3,EndDownB[SecSteps]);
SecSteps=SecSteps+1;
strip.show();
delay(100);
}
TimeIndex=TimeIndex+1;
}