bzuidgeest
New member
Hi all,
I'm using a octows2811 to drive 50 leds in a single strip as a test for audio visualization. When I use the teensyduino rainbow example to test my setup I get a perfectly smooth running rainbow effect. When I add the code for the audio connections the led strip starts to flicker. From the code on github I deduce that both are doing dma transfers and whatnot. This is unfortunately above my skill. The analog input is connected to pins 17/18 -A3/A4 for stereo input using the suggested input schematic seen in the designer for the audio libray. I'm guessing the reading of the analog input is interfering with the output to the leds somehow...
Is there any way to adjust the code below (simplest listing that shows the flickering derived from a sample) to prevent the led strip from flickering?
I'm using a octows2811 to drive 50 leds in a single strip as a test for audio visualization. When I use the teensyduino rainbow example to test my setup I get a perfectly smooth running rainbow effect. When I add the code for the audio connections the led strip starts to flicker. From the code on github I deduce that both are doing dma transfers and whatnot. This is unfortunately above my skill. The analog input is connected to pins 17/18 -A3/A4 for stereo input using the suggested input schematic seen in the designer for the audio libray. I'm guessing the reading of the analog input is interfering with the output to the leds somehow...
Is there any way to adjust the code below (simplest listing that shows the flickering derived from a sample) to prevent the led strip from flickering?
Code:
#include <Arduino.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <OctoWS2811.h>
// GUItool: begin automatically generated code
AudioInputAnalogStereo adcsInput(A3, A4); //xy=190,287
// GUItool: end automatically generated code
#include <OctoWS2811.h>
const int ledsPerStrip = 50;
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
int rainbowColors[180];
void setup() {
pinMode(1, OUTPUT);
digitalWrite(1, HIGH);
for (int i=0; i<180; i++) {
int hue = i * 2;
int saturation = 100;
int lightness = 50;
// pre-compute the 180 rainbow colors
rainbowColors[i] = makeColor(hue, saturation, lightness);
}
digitalWrite(1, LOW);
leds.begin();
}
void loop() {
rainbow(10, 2500);
}
// phaseShift is the shift between each row. phaseShift=0
// causes all rows to show the same colors moving together.
// phaseShift=180 causes each row to be the opposite colors
// as the previous.
//
// cycleTime is the number of milliseconds to shift through
// the entire 360 degrees of the color wheel:
// Red -> Orange -> Yellow -> Green -> Blue -> Violet -> Red
//
void rainbow(int phaseShift, int cycleTime)
{
int color, x, y, offset, wait;
wait = cycleTime * 1000 / ledsPerStrip;
for (color=0; color < 180; color++) {
digitalWrite(1, HIGH);
for (x=0; x < ledsPerStrip; x++) {
for (y=0; y < 8; y++) {
int index = (color + x + y*phaseShift/2) % 180;
leds.setPixel(x + y*ledsPerStrip, rainbowColors[index]);
}
}
leds.show();
digitalWrite(1, LOW);
delayMicroseconds(wait);
}
}