I have a few questions here -> I'm trying to interface an Arduino with a Vu meter to have some RGB Leds flick through at the pace of the music. I'm using 4 vu meter inputs (it's from a shirt, so the circuitry there is complete and works). I'm going to look at 4 of the last vu meter inputs, look at all four vu meter inputs, store them in an array, take the averages, put that an in array, cycle through a for loop that looks at the average, if average >= 0.5, fade up, if it's not, fade down. The trouble I'm facing now is figuring out how to use the other colors... I was thinking of taking a timer, looking at the fade status (it fades up for 0.5 seconds) and if it's no longer fading, and it's current at 4095, then I'll fade up the next color (LED + 1) then do that again for LED + 2.
I'm using a TLC5940, and in my recent testing with it just cycling through the default programs, it doesn't seem to be working properly. The LEDs are erratic and flicker quite heavily (noticeably). It's hooked up correctly - as the lights do work.
Some brief stats-
Arduino Duemilanove
TLC5940
4x RGB Leds
Sound reactive circuitry from electronic shirt.
For the sound reactive circuitry - the recorded voltage is a bit finicky. For some reason there's an inverter on the board that run out to the shirt, and the voltage fluctuates wildly. The chip on the board is a constant current chip, so maybe it throws up 80v to get 15 mA through my volt meter? Anyway, I'm going to use a voltage divider to bring the voltage down to something reasonable, as the Arduino has a 1 meg pull up resistor, the current going through that branch can be considered 0, right?
Here's the untested code that I currently have - I'm a bit stuck as the best route to go about actually running the lights, I'm currently looking at the average of 4 of the past inputs on a Vu input, if the average is > 0.5, it sets the LED to 4095 and starts fading down.
My code is having some trouble with this line ----
tlc_addFade(l, uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l), 0, startMillis, endMillis);
asking for a primary expression before Tlc5940, what's this mean?
Here's the code I'm currently working with...
#include "Tlc5940.h"
#include "tlc_fades.h"
int db0[] = {0,0,0,0};
int db1[] = {0,0,0,0};
int db2[] = {0,0,0,0};
int db3[] = {0,0,0,0};
int db0pin = 16;
int db1pin = 17;
int db2pin = 18;
int db3pin = 19;
int db0tot = 0;
int db1tot = 0;
int db2tot = 0;
int db3tot = 0;
int dbavg[] = {0,0,0,0};
int l = 0;
int x = 0;
void setup()
{
pinMode(db0pin, INPUT);
pinMode(db1pin, INPUT);
pinMode(db2pin, INPUT);
pinMode(db3pin, INPUT);
Serial.begin(9600);
Tlc.init();
}
void loop()
{
for(x = 0; x <= 3; x++)
{
db0[x] = analogRead(db0pin);
db1[x] = analogRead(db1pin);
db2[x] = analogRead(db2pin);
db3[x] = analogRead(db3pin);
}
for(x = 0; x <= 3; x++)
{
db0tot += db0[x];
db1tot += db1[x];
db2tot += db2[x];
db3tot += db3[x];
}
dbavg[0] = db0tot/4;
dbavg[1] = db1tot/4;
dbavg[2] = db2tot/4;
dbavg[3] = db3tot/4;
for(int t = 0; t <=3; t++) //offsetting for the LED selected
{
if(t == 1)
{
l = 3;
}
if(t == 2)
{
l = 6;
}
if(t == 3)
{
l = 9;
}
if(dbavg[t] < 0.5)
{
if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2)
{
uint16_t duration = 200;
uint32_t startMillis = millis() + 50;
uint32_t endMillis = startMillis + duration;
// tlc_addFade(l, uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l), 0, startMillis, endMillis);
// tlc_addFade(l+1, uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l+1), 0, startMillis, endMillis);
// tlc_addFade(l+2, uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l+2), 0, startMillis, endMillis);
}
tlc_updateFades();
}
else
{
if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2)
{
uint16_t duration = 150;
uint32_t startMillis = millis() + 50;
uint32_t endMillis = startMillis + duration;
tlc_addFade(l, uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l), 4095, startMillis, endMillis);
if(uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l) == 4095)
{
uint16_t duration = 100;
uint32_t startMillis = millis() + 50;
uint32_t endMillis = startMillis + duration;
tlc_addFade(l+1, uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l+1), 4095, startMillis, endMillis);
}
if(uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l+1) == 4095)
{
uint16_t duration = 50;
uint32_t startMillis = millis() + 50;
uint32_t endMillis = startMillis + duration;
tlc_addFade(l+2, uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l+2), 4095, startMillis, endMillis);
}
}
tlc_updateFades();
}
}
}
Every call to uint16_t Tlc5940::get(TLC_CHANNEL_TYPE l) generates an error.
Thanks!
tl;dr - Interfacing Arduino with Vu meter from shirt, code is acting a little finicky, the TLC5940 flickers with the default programs. Voltage from output of shirt is sporadic. Hmmm... maybe those weren't LEDs on the shirt...