#include struct mbr { uint32_t r; uint32_t g; uint32_t b; }; //Define output color mbr pnk={95,0,30}; mbr red={127,0,0}; mbr yel={62,62,0}; mbr grn={0,127,0}; mbr ble={0,0,127}; mbr none={0,0,0}; //Declare Spectrum Shield pin connections #define STROBE 4 #define RESET 5 #define LS A0 #define RS A1 #define band 7 //number of frequency band #define RES 9 //resolution //Threshold int th[RES] = {200,300,400,500,600,700,800,900,1000}; int th_low[RES] = {50,100,150,200,300,400,600,800,1000}; //Define spectrum variables int f_r[band]; int f_l[band]; int i; //Define NeoPixel Parameter #define LED_OUT 12 //LED output pin #define LED_NUM 30 //LED number on tape // Parameter 1 = number of pixels in strip // Parameter 2 = Arduino pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_NUM, LED_OUT, NEO_GRB + NEO_KHZ800); /********************Setup Loop*************************/ void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' // ******** Set spectrum Shield pin configurations ******************* pinMode(STROBE, OUTPUT); pinMode(RESET, OUTPUT); pinMode(LS, INPUT); pinMode(RS, 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_freq(); show_color(); //set_color(1, pnk); set_color(29, red); delay(30); reset_color(); } /*************Pull frquencies from Spectrum Shield****************/ void read_freq() { //Read frequencies for each band for (int f=0; f th_low[8]) { set_color(0, pnk); } else if(f_r[0] > th_low[7]) { set_color(0, red); } else if(f_r[0] > th_low[6]) { set_color(0, yel); } else if(f_r[0] > th_low[4]) { set_color(0, grn); } else if(f_r[0] > th_low[2]) { set_color(0, ble); } else { set_color(0, none); } if (f_l[0] > th_low[8]) { set_color(LED_NUM-1, pnk); } else if(f_l[0] > th_low[7]) { set_color(LED_NUM-1, red); } else if(f_l[0] > th_low[6]) { set_color(LED_NUM-1, yel); } else if(f_l[0] > th_low[4]) { set_color(LED_NUM-1, grn); } else if(f_l[0] > th_low[2]) { set_color(LED_NUM-1, ble); } else { set_color(LED_NUM-1, none); } for(int i=1; i th[8]) { set_color(i, pnk); } else if(f_r[i] > th[7]) { set_color(i, red); } else if(f_r[i] > th[6]) { set_color(i, yel); } else if(f_r[i] > th[4]) { set_color(i, grn); } else if(f_r[i] > th[2]) { set_color(i, ble); } else { set_color(i, none); } if (f_l[i] > th[8]) { set_color(LED_NUM-i-1, pnk); } else if(f_l[i] > th[7]) { set_color(LED_NUM-i-1, red); } else if(f_l[i] > th[6]) { set_color(LED_NUM-i-1, yel); } else if(f_l[i] > th[4]) { set_color(LED_NUM-i-1, grn); } else if(f_l[i] > th[2]) { set_color(LED_NUM-i-1, ble); } else { set_color(LED_NUM-i-1, none); } } } void set_color(int v, mbr m) { strip.setPixelColor(v, m.r, m.g, m.b); strip.show(); } void reset_color() { for(int w=0; w