Array variable 'does not name a type'

Hello! I'm having a strange issue I could use your help on...

I am defining some global variables outside the setup() and loop() methods. I'm having a problem with a float array I'm defining:

float noteFreq[3][12];

noteFreq[1][1] = 130.812782650299317; 
noteFreq[1][2] = 138.591315488436048;

I've tried starting at [0][0], nothing seems to work. Everything returns

'noteFreq' does not name a type

I would appreciate any insight. Thanks!

You declare the array at global scope. You do NOT initialize the array outside of a function, unless you do it as part of the declaration.

Also note, a float can NOT handle those numbers. It's only accurate to up to about 6 digits (not decimal places). And remember, a float isn't simply a decimal place!

Thanks for your response! That was it, I didn't realize, good to know! I moved the initialization into setup()

septillion:
Also note, a float can NOT handle those numbers. It's only accurate to up to about 6 digits (not decimal places). And remember, a float isn't simply a decimal place!

It can certainly “handle” the literals, though not adding precision

From arduino.h

#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398
#define TWO_PI 6.283185307179586476925286766559
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define RAD_TO_DEG 57.295779513082320876798154814105

Handle as in, the output will not be the same as the input :smiley:

Same as

byte val = 365673528884547278448;