adc compartor delay and save to memory

hi,

am haveing a small problem dont know what esle to do but post here
im basicly trying to write a software that would the values of an adc where apot is conected to it .. and compare that value to what ever that was there previously wait wait wait checks it out tell the change of values has stoped then saves it in memory

am not really good in programming here that much

i thought it was because the values were signed, i tried to make them unsigned didnt work .. declared them as long and double didnt work either plus i still havent figured how to get it to save to memory .. so ill just paste the code here and hope anyone has any commecnts

{
long ADC_OLD[5]; //The old ADC value
long ADC_NEW[5]; //The new ADC value
int Read_Count = 0;
do
{
ADC_NEW[0] = analogRead(0);

if( ( analogRead(0) <= (ADC_OLD[0] + 25) ) && ( analogRead(0) >=(ADC_OLD[0] - 25) ) ) //Compare ADC to ADC_OLD
{
Read_Count++; //increment
}
//else
//{
// if(Read_Count > 0) Read_Count--; //decrement
//}

//if((analogRead(0)>ADC_OLD[0]+ 25)&&(analogRead(0)<ADC_OLD[0])){
//}

delay(1); // wait for a milli second (1000ms = 1 second, so hand must not move for 1 second to produce result//
for(int j=0; j<=4;j++) ADC_OLD[j] = analogRead(j); //At the end of the function eqaute
}while(Read_Count < 1000);

i thought it was cuz the adc in the arduino is 10bits and am defining it as 8 bits for the data types in ADC_OLD but no luck there either

please help

tried it with unsigned long as well as a data type it didnt work
cant get the function compare the values here and compare it to what was there and what will be there it just goes on to delay 1ms

then ends :cry:

am not really good in programming here that much

Sorry you are not much good at explaining what you want to do either. Probably English is not your first language but it is hard to understand what you want to do and even harder to understand why you want to do it. Also please use the hash key to post code.

So let me get this straight:-

  1. Measure the value from a pot.
  2. Compare it to what it was - this doesn't make sense as it never was anything the first time round - do what with the result of this comparison?
  3. Do some sort of delay.
  4. Measure it again and if it is the same as last time - then what. You say store it in memory but it is in memory already in the form of a variable.

If we know what you want to do and possibly why then we might be of some help.

This:

ADC_NEW[0] = analogRead(0);
   
   if( ( analogRead(0) <= (ADC_OLD[0] + 25) ) && ( analogRead(0) >=(ADC_OLD[0] - 25) ) )  //Compare ADC to ADC_OLD

should look more like this (I think)

ADC_NEW[0] = analogRead(0);
   
   if( ( ADC_NEW[0] <= (ADC_OLD[0] + 25) ) && ( ADC_NEW[0] >=(ADC_OLD[0] - 25) ) )  //Compare ADC to ADC_OLD