Where do I find my variable?


Actually, you do not need to know this. And it will change with the next version of your program. But if you still want to know it this ist how it can be done:

byte *pointer; 
int counter;

void setup() {
  Serial.begin(9600);   
  pointer = 0;
  counter = 0;
  //------------------------------
  byte a = 123; // my variable
  //------------------------------
  byte *aux = &a; 
  // look for aux by incrementing pointer incrementiert until it points to  a 
  do { counter++; pointer++; } while (pointer != aux);
  Serial.print("address of a: ");
  Serial.println(counter);
  // this also works with Special Function Registers:
  volatile byte *t = &TIMSK2; //  uint8_t
  pointer = 0;
  counter = 0;
  // look for aux by incrementing pointer incrementiert until it points to TIMSK2  
  do { counter++; pointer++; } while (pointer != t);
  Serial.print("address of TIMSK2: ");
  Serial.println(counter); 
}

void loop() { }

Note:
if the size of the type of the variable is 2 bytes or 4 bytes you have to multiply counter by this value.

... years later ...

C would not be C if you could not fool around with data type casting (if necessary at all).

So, things are so easy ...

void setup() {
  Serial.begin(9600);   
  byte a = 123; 
  int b = 1234;
  long c = 123456;
  long long d = 1234567890;
  byte e = 234;
  byte f = 231;
  Serial.println( (int) &a);
  Serial.println( (int) &b);
  Serial.println( (int) &c);
  Serial.println( (int) &d);
  Serial.println( (int) &e);
  Serial.println( (int) &f);
  Serial.println( (int) &TIMSK2);
}

void loop() { }


2277      
2280
2282
2286
2278
2279
112
Note:
As you can see the bytes are grouped together.
The compiler always places word and long data at even addresses.


contact: nji(at)gmx.de