keyword to store value(final)

hi,
Final keyword is not supporting in arduino programming, what is the keyword i can use to store value finally (it is not constant value)

Final is not a C concept - it is Java.

In C values are either constant or variable. If you specify the value at compile time it is constant

const int val = 4;

If you change the value from its compile time value then it is variable. There is no "change once and never change again" concept, and if you ask me that's a daft concept to even consider.

If you change the value from its compile time value then it is variable. There is no "change once and never change again" concept, and if you ask me that's a daft concept to even consider.

I don't know. I can envision a scenario where you might want to read values from a sensor for the first minute, to establish the range of values that define min and max. You might, at the end of that minute want to "change once" and then never change again.

Of course, you can use regular variables and boolean flags to accomplish the same thing.

actually i am using accelerometer and i am getting readings from the sensor.now i am store the constant reading of x and y in a,b in horizontal position of quadcopter.after that i am comparing the readings from sensor with a,b after increasing speed of motors so that ican balance the position but it is not working.please tell
i have only problem in case 5

#include <Servo.h>

Servo m3,m5,m9,m11;
const int groundpin = 14;             // analog input pin 4 -- ground
const int powerpin = 19;              // analog input pin 5 -- voltage
const int xpin = A1;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A3;
int xin,yin,zin;// z-axis (only on 3-axis models)
#define X_ZERO 332
#define Y_ZERO 324
#define Z_ZERO 396
#define ACCEL_CON 0.93
#define TIME_CON 0.02
#define SEN_CON 0.95
int x=0,y=0,z=0;// create servo object to control a servo

float s1,s3,s5,s9,s11;
int val=0;    // variable to read the value from the analog pin
float val1,val2,val3,val5,val9,val11;
int temp=0,a=0,b=0;
void setup() 
{ 
  pinMode(2,INPUT);  
pinMode(4,INPUT);
  pinMode(6,INPUT);  
pinMode(8,INPUT); 
  pinMode(10,INPUT); 
  m1.attach(3);  
  m2.attach(5);
  m3.attach(9);
  m4.attach(11);
  attachInterrupt(0,dtmf,RISING);
  Serial.begin(9600); 
} 
 
void loop() 
{ xin=(analogRead(A1));
yin=(analogRead(A2));
zin=(analogRead(A3));
int x=map(xin,317,460,-90,90);
int y=map(yin,311,480,-90,90);
if(temp<4)
{
a=x;
b=y;
temp++;
}
 if(val!=0)
  {
   Serial.println(val); // print the new value to the serial monitor
   val = 0; // reset the value to 0
  }
}
void dtmf() // the ISR - this function is called everytime a RISING interrupt occurs on PIN 2 (INT 0)
{
  for(int i=1;i<5;i++) // Once we receive an Interrupt, we need to read each of q1 to q4, with q1 being the LSB and q4 the MSB
  {
    if(digitalRead(i+i+2)==1)// check if the pin is 1 or 0, if 1 then we need to process for binary to decimal conversion
    {
      val =digitalRead(4)+2*digitalRead(6)+4*digitalRead(8)+8*digitalRead(10);
      switch (val)
      {
         case 1:
         s1=583;
 val1 = map(s1, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  m1.write(val1);
m2.write(val1);
m3.write(val1);
m4.write(val1);// sets the servo position according to the scaled value
break;
     case 5:
s5 =s5 +0.74;
s3 =s3 +0.74;
s9 =s9 +0.86;
s11=s11+0.5;

val5=map(s5,0,1023,0,1023);
val3=map(s3,0,1023,0,1023);
val9=map(s9,0,1023,0,1023);
val11=map(s11,0,1023,0,1023);

m5.write(val5);
m3.write(val3);
m9.write(val9);
m11.write(val11);

xin=(analogRead(A1));
yin=(analogRead(A2));
x=map(xin,317,460,-90,90);
y=map(yin,311,480,-90,90);

do{

xin=(analogRead(A1));
x=map(xin,317,460,-90,90);
if(x<a)
{
s9=s9+0.01;
val9=map(s9,0,1023,0,1023);
m9.write(val9);
} 
else
{
s11=s11+0.01;
val11=map(s11,0,1023,0,1023);
m11.write(val11);
}

}while(x!=a);


do{

yin=(analogRead(A2));
y=map(yin,311,480,-90,90);
if(y<b)
{
s5=s5+0.01;
val5=map(s5,0,1023,0,1023);
m5.write(val5);
} 
else
{
s3=s3+0.01;
val3=map(s3,0,1023,0,1023);
m3.write(val3);
}

}while(y!=b);
break;
            default:
            for(s1=0;s1<110;s1++)
            {
  val1 = map(s1, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  m1.write(val1);
m2.write(val1);
m3.write(val1);
m4.write(val1);// sets the servo position according to the scaled value 
            }
break;
      }
    }
  } 
}
  // waits for the servo to get there

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

I was about to comment on the use of code tags.
It's a pity though that the code does not compile.

To my eyes there is way too much happening in the ISR. What is connected to pin 2 to cause the interrupt ?

val5=map(s5,0,1023,0,1023);
val3=map(s3,0,1023,0,1023);
val9=map(s9,0,1023,0,1023);
val11=map(s11,0,1023,0,1023);

What is this crap? Mapping from one range to the same range is stupid.