[good enough] Color wheel Neopixel math help

Hey guys, just looking for a bit of help with some math and a color wheel.

I’m playing with the MSGEQ7 (datasheet) and throwing 7 frequency bands onto an 8x8 NeoMatrix grid. It’s working ok - I currently have each row mapped to an increasingly higher frequency (row 1 (leds 0-7) is 63Hz, row 2 is 160Hz, so on). Pixel output code looks like so:

for(int i=0;i<7;i++){
  ledValue = map(spectrumValue[i], 0, 1023, 0, 255);    
  c = strip.Color(0,0,ledValue);

  for(int j=0;j<7;j++){
    strip.setPixelColor(j+(8*i), c );

So each row corresponds to the analogRead value in the spectrumValue[i] array. I would like to accomplish 2 more things (may not be possible together):

  1. Have each row a different color, working through the color wheel. 8 rows, 8 different colors (1 color per row)
  2. (Long shot) Have each row only light the pixels 0-7 representing the overall intensity of the analog value, much more like a traditional spectrum analyzer.

I thought about mapping green and red channels as well, like:

grnVal = map(i, 0, 7, 0, 255);
redVal = map(i, 0, 7, 0, 255);
c = strip.Color(grnVal, redVal ,ledValue);

… but this just produces some boring colors ranging from white to yellow. Not too concerned about #2, but does anybody have an idea of how to programatically adjust colors cycling through the wheel? Will reward with video!

Video for the curious:

Well, an afternoon of code gets us here:

Great fun!

edit: code for the hungry. http://pastebin.com/76QtpV5q

1 Like

Aaaand because I know you guys like watching videos, here’s me in an interview - it’s a project that my girlfriend is doing for school. Turns out I suck at interviews.