We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

1

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 ...


0

There is absolutely nothing wrong with putting it in the header. §9.4.2/4 If a static data member is of const integral or const enumeration type, its declaration in the class definition can specify a constant-initializer which shall be an integral constant expression (5.19). In that case, the member can appear in integral constant expressions. The ...


1

The reason is that in your sketch you import only the header file (which is good). However, there it is an array (int[]), not the initialized array. For that you would need to include the cpp but that is bad practice (if even possible). So instead, create a new (constant) variable, and assign it. (more or less pseudo code, due to lack of a compiler): Lib....


2

You can't. You are passing a pointer to the array, and sizeof will give you the size of that pointer (2 on an 8-bit Arduino). Instead the normal way is to pass the size of the array as a parameter to your function. myFunction(myArray, sizeof(myArray) / sizeof(myArray[0]));


Top 50 recent answers are included