HI.
I have been playing with code and asking chat gpt to help.
I have tested Leds are turning on or connected right with a simple program.
https://cdn.sparkfun.com/assets/learn_t … kup_bb.jpg
I have the board wired as in the link.
https://github.com/sparkfun/Spectrum_Sh … m_Demo.ino
https://github.com/sparkfun/Spectrum_Sh … M_Demo.ino
These are the 2 codes i have been trying and attempting to tweak.
/******************************************************************************
SparkFun Spectrum Shield Demo
Toni Klopfenstein @ SparkFun Electronics
December 2015
https://github.com/sparkfun/Spectrum_Shield
This sketch shows the basic functionality of the Spectrum Shield, working with a basic RGB LED Matrix.
The Spectrum Shield code is based off of the original demo sketch by Ben Moyes @Bliptronics.
This sketch is available in the Spectrum Shield repository.
Development environment specifics:
Developed in Arduino 1.6.
This code is beerware; if you see me (or any other SparkFun employee) at the local, and you’ve found our code helpful, please buy us a round!
Distributed as-is; no warranty is given.
*********************************************************************************/
// Declare Spectrum Shield pin connections
#define STROBE 4
#define RESET 5
#define DC_One A0
#define DC_Two A1
// Define LED connections on the Arduino/Shield
int LED = {7, 8, 9, 10, 11, 12, 13};
// Define spectrum variables
int freq_amp;
int Frequencies_One[3];
int Frequencies_Two[3];
int i;
// Define LED frequency ranges
int ledFrequencyRanges[2] = {
{60, 130}, // LED 7 - Frequency range 20Hz to 60Hz
{140, 200}, // LED 8 - Frequency range 60Hz to 250Hz
{200, 500}, // LED 9 - Frequency range 250Hz to 500Hz
{500, 1000}, // LED 10 - Frequency range 500Hz to 1000Hz
{1000, 2000}, // LED 11 - Frequency range 1000Hz to 2000Hz
{2000, 4000}, // LED 12 - Frequency range 2000Hz to 4000Hz
{10000, 15000} // LED 13 - Frequency range 4000Hz to 6000Hz
};
/Setup Loop*****/
void setup() {
// Set LED pin configurations
for (i = 0; i < 5; i++) {
pinMode(LED*, OUTPUT);*
digitalWrite(LED, LOW);
}
// Set Spectrum Shield pin configurations
pinMode(STROBE, OUTPUT);
pinMode(RESET, OUTPUT);
pinMode(DC_One, INPUT);
pinMode(DC_Two, INPUT);
digitalWrite(STROBE, HIGH);
digitalWrite(RESET, HIGH);
// Initialize Spectrum Analyzers
digitalWrite(STROBE, LOW);
delay(1);
digitalWrite(RESET, HIGH);
delay(1);
digitalWrite(STROBE, HIGH);
delay(1);
digitalWrite(STROBE, LOW);
delay(1);
digitalWrite(RESET, LOW);
}
/Main Function Loop***/
void loop() {
Read_Frequencies();
Light_LEDs();
}
/Pull frequencies from Spectrum Shield*/
void Read_Frequencies() {
// Read frequencies for each band
for (freq_amp = 0; freq_amp < 7; freq_amp++) {
Frequencies_One[freq_amp] = analogRead(DC_One);
Frequencies_Two[freq_amp] = analogRead(DC_Two);
digitalWrite(STROBE, HIGH);
digitalWrite(STROBE, LOW);
}
}
/Light LEDs based on frequency detection**********/
void Light_LEDs() {
for (i = 0; i < 7; i++) {
// Check if frequency range matches LED
if (Frequencies_Two >= ledFrequencyRanges[0] && Frequencies_Two < ledFrequencyRanges[1]) {
digitalWrite(LED, HIGH);
} else {
digitalWrite(LED, LOW);
}
}
}
This is the latest code after an evening of many codes with chat gpt.
The effect of the project i am looking for is leds flashing on in time to the beats or different frequencies. When this is acheived the next stage will be sending the voltage to relays turning on and off in time to the music.
I have tried a line in from a mixer, phone and laptop. With one code i was getting interference with a usb cable which meant flickering leds with no signal.
I have thought i made need pots as an input to adjust frequency ranges live as the board processes different songs. Is the board meant for live or prerecorded. I think the video with chris taylor and the fire used a pre recorded track.
Can you recomend another way to process live sound beats and trigger relays if we cant get the board to work.
Thank