Using Arrays and LED's to represent Piano Scales I am trying to use addressable LED's to show various piano scales using the semi notes formula for each scale as an array and an input to indicate the starting note.

int MajorScale[] = {2,2,1,2,2,2,1}; //represents the semi notes in a major scale
int t= 8 //represents the led number that represent the first C on the keyboard


The following leds should light up - 

(8, 8+2, 8+2+2, 8+2+2+1, 8+2+2+1+2, 8+2+2+1+2+2, 8+2+2+1+2+2+2 , 8+2+2+1+2+2+2+1)  // This is first C Major Scale on the Piano 

so..
(8,10,12,13,15,17,19) // This is first C Major Scale on the Piano where 8 is the first c 

Then light up all the other C Major scales available on the piano limited by the number of keys on the piano in this case 76 keys 

As there are 12 notes for each octave , add this to the array 

if i take just the C note 

8, 8+12, 8+12+12 ,8+12+12+12, 8+12+12+12+12  etc 

My code so far just lights up the semitone that i set up in the array 

enter code here
#include "FastLED.h"
#define DATA_PIN 5
#define NUM_LEDS 76
#define BRIGHTNESS 10
CRGB leds[NUM_LEDS];
int MajorScale[] = {2,2,1,2,2,2,1};
int delayValue = 1000;

void setup() {
Serial.begin(9600); // open the serial port at 9600 bps:
FastLED.addLeds&lt;WS2812B, DATA_PIN, GRB&gt;(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
}

void loop() {
for(int i = 0; i &lt;=6; i++)
{  
    leds[MajorScale[i]] = CRGB::BlueViolet;  
    FastLED.show();          
     delay(delayValue);

}

FastLED.clear();
}
Your current code will not show all notes of a scale. Only the notes at 1 and 2 will light up, since you don't sum up the numbers, that you have stored in MajorScale. But I think it is not a great idea to sum them up programatically, since this is a constant and you don't win much by representing the data this way. Instead you should directly initiate the MajorScale variable with the summed up values:

int MajorScale[] = {0, 2, 4, 5, 7, 9, 11};


Then you can enclose your for loop with another for loop, that adds an offset corresponding to the octave:

for(int j=0; j&lt;NUM_LEDS; j+=12){
    for(int i=0; i&lt;=6 &amp;&amp; MajorScale[i]+j&lt;NUM_LEDS;i++){
        leds[8+MajorScale[i]+j] = CRGB::BlueViolet;
        FastLED.show();
        delay(delayvalue);
    }
}


So we set the LED number 8+MajorScale[i]+j. 8 for the offset to C, MajorScale[i] as the position of the note in the current octave and j for the offset of the current octave relative to the C.

Note, that this is not tested in any way.