Bit manipulation of sensor data

Hello , thank you for the feedback .

for (int i=0; i<noOfSamples; i++)
    {
      rawdata[i] = PIOC->PIO_PDSR;
      
    }

Do you mean the I should try to combine the rawdata*--->value , and then compare it with reference value. It should look like this ? Yes at the moment i am very confused as well.*
* *for (int i=0; i<noOfSamples; i++)     {       rawdata[i] = PIOC->PIO_PDSR;   // Combine the received value with bit shifting   // Value -->rawData[i]           }* *

Do you mean the I should try to combine the rawdata--->value , and then compare it with reference value.

Yes, if you want to use the numerical difference method instead of a bitwize comparison to determine the +/- shift from the reference.

[Commentary: I don't fully understand your project, and how the reference may change, and if there may be alternating 0 and 1 in the value or reference, so I'm not sure of the best approach. You have chosen to pursue the numerical difference path, so lets stick with that for now.]

Received_Binary[1]=Actual_Binary[1];
  Received_Binary[2]=Actual_Binary[2];
  Received_Binary[3]=Actual_Binary[3];
  Received_Binary[4]=Actual_Binary[4];
  Received_Binary[5]=Actual_Binary[5];
  Received_Binary[6]=Actual_Binary[6];
  Received_Binary[7]=Actual_Binary[7];
  Received_Binary[8]=Actual_Binary[8];
  Received_Binary[9]=Actual_Binary[9];
  Received_Binary[10]=Actual_Binary[14];
  Received_Binary[11]=Actual_Binary[15];
  Received_Binary[12]=Actual_Binary[16];
  Received_Binary[13]=Actual_Binary[17];
  Received_Binary[14]=Actual_Binary[18];
  Received_Binary[15]=Actual_Binary[19];

From looking at your Serial prints of Received_Binary and how you compare it to the reference,

for (int i=1; i<16;i++)
 { 
   
  Serial.print( Received_Binary[i]);
 
 }

your bit ordering is reversed from common convention which usually puts the first bit at the right (LSB) and the nth bit at the left(MSB), and starts with bit 0 (LSB) not bit 1, but we can stick with what you have.

From this code, and the Due pin mappings I assume that your input connections are on pins 33-41 for the top 9 bits, and then on pins 49-44 for the last 6. This pin arrangement adds complexities to combining the bits into one value.

Here's a basic way to assemble a value using digitalRead(). I showed port reads and bit shifting to clear unwanted bits in a previous post.

int value = 0; //clear previous value
    for (byte i = 33; i <= 41; i++)
    {
      value = value << 1; //multiply by 2 to shift value
      value += (digitalRead(i)); //add new bit
    }
    for ( byte i = 49; i >= 44; i--)
    {
      value = value << 1; //multiply by 2 to shift value
      value += (digitalRead(i)); //add new bit
    }

I don't understand why in your previous code, the Actual_Binary bit values were not transferring correctly to the Received_Binary bit values and your print out of Received_Binary[] had a 0 within the string of 1's.
It was printing out 111111010000000 for a Received_Binary value which is not valid according to your earlier postings.

Hello
As you mentioned that I should rethink the way to calculate the deviation I was wondering if it was possible just to do a comparison of two arrays . Perhaps that way one can avoid the combining of the bits using digital read ? and also to avoid confusion and misunderstandings ?
For example something like this ??

// Neutral point  the bit pattern 111111000000000
// Deviation_one 111000000000000
Serial.print ("  <----Send Data ----->       ");
for (int i=1; i<16;i++)
 { 
   
  Serial.print( Received_Binary[i]);

 if (Received_Binary[i] == Neutralpoint )
return 0;
if (Received_Binary[i] == Deviation_one 
return 30 ; 
........
 // Collecting all possible combinations ??? 

 }

and also to avoid confusion and misunderstandings ?

 if (Received_Binary[i] == Neutralpoint )

You are still not understanding a key issue. You can only compare a bit value to another bit value, not a number which consists of many bits. You were trying to avoid bit shifting and masks so comparing two numbers looked easier.

The comparing number to number approach is not bad.

Perhaps that way one can avoid the combining of the bits using digital read ?

What is your problem with combining the bits? Get it working with digitalRead() which is easy to understand. If that method is too slow, then use the port reading and bit shifting/masking as shown in an earlier post.

Here is another way to do your comparison to the reference. It uses memcmp to compare the received array to the reference. You do not need to combine the received bits.

Since your received arrays are fixed and the reference array is known, you actually only need to identify the received array to know the difference from the reference.

const byte possibleReceivedValue[15][15] =
{
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};

//referenceValue 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
//matches possibleReceivedValue[6][15]

byte actualReceivedValue[15] = {};

byte matchNumber;

void setup() {
  Serial.begin(115200);
}

void loop() {
  //random test loop to create actualReceivedValue
  Serial.println("         |      ");//mark reference length
  byte r = random(0, 15);//exclusive of upper bound
  for (byte k = 0; k < 15; k++)
  {
    actualReceivedValue[k] = possibleReceivedValue[r][k];
    Serial.print(actualReceivedValue[k]);
  }
  Serial.println();

  //test for match with memcmp

  for (byte i = 0; i <= 15; i++)
  {
    if ((memcmp(actualReceivedValue, possibleReceivedValue[i], 15)) == 0)
    {
      matchNumber = i;
      Serial.print("receivedValue matches possibleValue =  ");
      Serial.println(i);
    }
  }
  switch (matchNumber)
  {
    case 0:
      Serial.println("+6X");
      break;

    case 1:
      Serial.println("+5X");
      break;

    case 2:
      Serial.println("+4X");
      break;

    case 3:
      Serial.println("+3X");
      break;

    case 4:
      Serial.println("+2X");
      break;

    case 5:
      Serial.println("+1X");
      break;

    case 6:
      Serial.println("no difference");
      break;

    case 7:
      Serial.println("-1X");
      break;

    case 8:
      Serial.println("-2X");
      break;

    case 9:
      Serial.println("-3X");
      break;

    case 10:
      Serial.println("-4X");
      break;

    case 11:
      Serial.println("-5X");
      break;

    case 12:
      Serial.println("-6X");
      break;

    case 13:
      Serial.println("-7X");
      break;

    case 14:
      Serial.println("-8X");
      break;
  }
  delay(2000);
}

Could also make a smaller array

const int possibleReceivedValue[15] =
{
0x7ff, //  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
0x7fe, // {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
0x7fc, //  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
0x7f8, //  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
0x7f0, //  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0},
0x7e0, //  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0},
0x7fc0, //  {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
0x7f80, //  {1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
0x7f00, //  {1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
0x7e00, //  {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
0x7c00, //  {1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
0x7800, //  {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
0x7000, // {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 0x6000, // {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
0x4000, //  {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};

30 bytes vs 225
Gotta be easier to compare also I would think.

Yes Crossroads, using integer values instead of byte arrays is correct. That approach was suggested earlier in this thread, but, for some reason, the OP is having problems combining his individually received bit values into an actual number. The memcmp of the array was an attempt to show him another path which perhaps he could more easily understand.

Hello thank you for the help for the way you mentioned in the post. If I understand correctly , here we have a defined a set of patters to compare It in the declaration possibleReceivedValue.

And then you have generated a random sequence to simulate the received value in the form of

byte r = random(0, 15);//exclusive of upper bound
  for (byte k = 0; k < 15; k++)
  {
    actualReceivedValue[k] = possibleReceivedValue[r][k];
    Serial.print(actualReceivedValue[k]);
  }

And the actual matching is done in the following

for (byte i = 0; i <= 15; i++)
  {
    if ((memcmp(actualReceivedValue, possibleReceivedValue[i], 15)) == 0)
    {
      matchNumber = i;
      Serial.print("receivedValue matches possibleValue =  ");
      Serial.println(i);
    }
  }

For the case I am working in , I have the actualReceivedValue in the form of Received_Binary from the following set

Serial.print ("  <----Send Data ----->       ");
for (int i=1; i<16;i++)
 {
   Serial.print( Received_Binary[i]);
 }

For the memcmp method to work , I have to have to , I think get the Received_Binary stored in some array ? Is it possible to declare something like
byte Received_Binary_Store [15] ={} (it was also described in your code )
to store the Received_Binary values . I think then only the memcmp will work to do some matching ?

Actual sketch

#include <LCD5110_Graph.h>
#include "MabSerialCom.h"
#define serialPin2 16

#define noOfSamples 350
int rawdata[noOfSamples]; 
int relPos[32];
int lengthOfSample[32];
byte Actual_Binary[32];
byte  Received_Binary[32];
int i, Global_Trig;
int High = 110;
int Low = 40;
int difference = 0;
uint32_t SendData ;
uint32_t SendSignal ;   

byte actualReceivedValue[15] = {};

byte matchNumber;
void setup()
  {               
    initSerialConnection(serialPin2);
   
    PIOB -> PIO_OER = 0b11111111111111111111111111111111 ;   
    PIOC -> PIO_ODR = 0b00000000000111111111111111111111 ;   
    PIOC -> PIO_PER = 0b11111111111111111111111111111111 ;   
   
    Serial.begin(115200);

    pinMode (33, INPUT) ;
    pinMode (49, INPUT) ;
   }

void loop() {

 for (int i=0; i<noOfSamples; i++)
    {
      rawdata[i] = PIOC->PIO_PDSR;
     
    }




Global_Trig = Trigger1(19 );

 for (int i=0; i<31; i++)
    { 
      relPos[i]=RelativeData(i,Global_Trig);
    } 

 for (int i=0; i<31; i++)
  { 
       if  (((relPos[i]) > High) || ((relPos[i]) < Low))
          {
             Actual_Binary[i]= 0;
             bitSet(SendData,i);
          }
      else
          {
            Actual_Binary[i]= 1;
            bitClear(SendData,i);
           }
  }
 

  for (int i=0; i<31; i++)
    {
 lengthOfSample[i]=Calc_Period_time(i);
      { 
       if  ((lengthOfSample[i]) > 40 )
          {     
            bitSet(SendSignal,i);
          }
      else
          {
            bitClear(SendSignal,i);
          }
       }   
   
  }
   
  Received_Binary[1]=Actual_Binary[1];
  Received_Binary[2]=Actual_Binary[2];
  Received_Binary[3]=Actual_Binary[3];
  Received_Binary[4]=Actual_Binary[4];
  Received_Binary[5]=Actual_Binary[5];
  Received_Binary[6]=Actual_Binary[6];
  Received_Binary[7]=Actual_Binary[7];
  Received_Binary[8]=Actual_Binary[8];
  Received_Binary[9]=Actual_Binary[9];
  Received_Binary[10]=Actual_Binary[14];
  Received_Binary[11]=Actual_Binary[15];
  Received_Binary[12]=Actual_Binary[16];
  Received_Binary[13]=Actual_Binary[17];
  Received_Binary[14]=Actual_Binary[18];
  Received_Binary[15]=Actual_Binary[19];



Serial.print ("  <----Send Data ----->       ");
for (int i=1; i<16;i++)
 {
   
  Serial.print( Received_Binary[i]);


 }
Serial.print("\n");
delay(2000);

 }
 
int Trigger1(int Data )
  {
     int count;
     int mask= pow(2,Data);

     count =  0;
     while (( (rawdata[count] & mask) == mask ) &  (count < noOfSamples))
      {
        count++;
      }
     while (((rawdata[count] & mask)!= mask) &  (count < noOfSamples))
      {
        count++;
      }
      return(count);
           
   }


int RelativeData(int Data, int Trig_1 )
  {  int count;
     int mask= pow(2,Data);
     count =Trig_1;
   
     while (( (rawdata[count] & mask) == mask ) &  (count < noOfSamples))
      {
       
         count++;
      }

     while (((rawdata[count] & mask)!= mask) &  (count < noOfSamples))
      {
       
        count++;
       
      }


            return (count-Trig_1);
  }

int Calc_Period_time(int Data )
  {
     int Time_period, Slack_Count;                       
     int mask= pow(2,Data);       
     Slack_Count=0;

      while (((rawdata[Slack_Count] & mask)== mask) &  (Slack_Count < noOfSamples))
            {
         
            Slack_Count++;
            }
     
     while (( (rawdata[Slack_Count] & mask) != mask ) &  (Slack_Count < noOfSamples))
            {
         
            Slack_Count++;
            }
            Time_period =Slack_Count;
 
     while (((rawdata[Time_period] & mask)== mask) &  (Time_period < noOfSamples))
            {
   
            Time_period++;
            }

     return (Time_period-Slack_Count);
  }

I think you are understanding.

//byte  Received_Binary[32];
byte Received_Binary[15];

You declare an array of byte values with 32 elements. If you don't need all 32 values, then you should use Received_Binary[15].

You do not need to declare another byte array Received_Binary_Store [15] ={}

You fill some of the array with values in this piece of code. The values come from the individual pin readings extracted from a port reading.

Received_Binary[1]=Actual_Binary[1];
  Received_Binary[2]=Actual_Binary[2];
  Received_Binary[3]=Actual_Binary[3];
  Received_Binary[4]=Actual_Binary[4];
  Received_Binary[5]=Actual_Binary[5];
  Received_Binary[6]=Actual_Binary6];
  Received_Binary[7]=Actual_Binary[7];
  Received_Binary[8]=Actual_Binary[8];
  Received_Binary[9]=Actual_Binary[9];
  Received_Binary[10]=Actual_Binary[14];
  Received_Binary[11]=Actual_Binary[15];
  Received_Binary[12]=Actual_Binary[16];
  Received_Binary[13]=Actual_Binary[17];
  Received_Binary[14]=Actual_Binary[18];
  Received_Binary[15]=Actual_Binary[19];

Arrays are zero indexed, and it will help in your testing against the pattern arrays if the Received_Binary index started at 0 and went up to 14 such that the elements of the Received_Binary array are Received_Binary[0] .... to...ReceivedBinary[14].

Received_Binary[0]=Actual_Binary[1];
  Received_Binary[1]=Actual_Binary[2];
  Received_Binary[2]=Actual_Binary[3];
  Received_Binary[3]=Actual_Binary[4];
  Received_Binary[4]=Actual_Binary[5];
  Received_Binary[5]=Actual_Binary6];
  Received_Binary[6]=Actual_Binary[7];
  Received_Binary[7]=Actual_Binary[8];
  Received_Binary[8]=Actual_Binary[9];
  Received_Binary[9]=Actual_Binary[14];
  Received_Binary[10]=Actual_Binary[15];
  Received_Binary[11]=Actual_Binary[16];
  Received_Binary[12]=Actual_Binary[17];
  Received_Binary[13]=Actual_Binary[18];
  Received_Binary[14]=Actual_Binary[19];

You will then use memcmp to test the Received_Binary array against the set of patterns.

From some of your previous postings, there are issues with the extraction of the Actual_Binary values from the port readings, as you were showing invalid patterns.

Hello , thank you for the reply. Yes now I seem to have a bit more better understanding of the sketch. after correcting the index i noted down the pattern of the bits. So for my case i re-made the possibleReceivedValue Matrix. the bit pattern , noted was as follows

111111000000000 X= 0;
111111010000000 X=+15
111111011000000 X=+30
111111011100000 X=+45
111111011110000 X=+60
111111011111000 X=+75
111111011111100 X=+90
111111011111110 X=+105
111110111111111 x=+120
111110000000000 X=-15
111100000000000 X=-30
111000000000000 X=-45
110000000000000 X=-60
100000000000000 X=-75
000000000000000 X=-90

I just changed a bit in the switch case part of the code and printed out strings instead. (Basically just for my understanding as follows

for (byte i=0; i<15;i++)
 {

  Serial.print( Received_Binary[i]);
  // Do memcmp here & switch Case 
  if ((memcmp(Received_Binary, possibleReceivedValue[i], 15)) == 0)
    {
      matchNumber = i;
     
    }

  }
  
  switch (matchNumber)
  {
    case 0:
      Serial.print("\t");
      Serial.print("It is at neutral point");
      break;

    case 1:
      Serial.print("\t");
      Serial.print("+15 mm to the right");
      break;

    case 2:
      Serial.print("\t");
      Serial.print("+30 mm to the right");
      break;

    case 3:
      Serial.print("\t");
      Serial.print("+45 mm to the right");
      break;

    case 4:
      Serial.print("\t");
      Serial.println("+60 mm to the right ");
      break;

    case 5:
      Serial.print("\t");
      Serial.println("+75 mm to the right ");
      break;

    case 6:
      Serial.print("\t");
      Serial.println("+90 mm to the right ");
      break;

    case 7:
      Serial.print("\t");
      Serial.println("+105 mm to the right ");
      break;

    case 8:
      Serial.print("\t");
      Serial.println("+120 mm to the right ");
      break;

    case 9:
      Serial.print("\t");
      Serial.println("-15 mm to the left");
      break;

    case 10:
      Serial.print("\t");
      Serial.println("-30 mm to the left");
      break;

    case 11:
      Serial.print("\t");
      Serial.println("-45 mm to the left");
      break;

    case 12:
      Serial.print("\t");
      Serial.println("-60 mm to the left");
      break;

    case 13:
      Serial.print("\t");
      Serial.println("-75 mm to the right ");
      break;

    case 14:
      Serial.print("\t");
      Serial.print(" Invalid data ");
      break;
  }
Serial.print("\n");
delay(1000);

 }

I was wondering if it is possible to send integer values for each of the cases ? For example by declareing Actual_Value of type int and returning a corresponding value for each case ??
Example

 int Actual_Value ;
 switch (matchNumber)
  {
    case 0:
      Serial.print("\t");
      Serial.print("It is at neutral point");
      return Actual_Value 0;
      break;

    case 1:
      Serial.print("\t");
      Serial.print("+15 mm to the right");
      return Actual_Value 15;
      break;

    case 2:
      Serial.print("\t");
      Serial.print("+30 mm to the right");
      return return Actual_Value 30;
      break;

well

      return Actual_Value 0;

won't do probably what you want...

Assuming you are in a function that is declared as returning an int, the you can only do something like

      return Actual_Value;

or did you mean

      return Actual_Value [color=red]+[/color] 0; (that's ok)

Good progress in understanding the test patterns.

I was wondering if it is possible to send integer values for each of the cases ? For example by declareing Actual_Value of type int and returning a corresponding value for each case ??

You can declare Actual_Value as a global variable. Assign it a value in the switch case statement, and use it elsewhere in the sketch.

The switch case actions can not be treated as functions which return a value.

 int Actual_Value ;//declare this as a global variable
 switch (matchNumber)
  {
    case 0:
      Serial.print("\t");
      Serial.print("It is at neutral point");
      Actual_Value = 0;
      break;

    case 1:
      Serial.print("\t");
      Serial.print("+15 mm to the right");
      Actual_Value = 15;
      break;

    case 2:
      Serial.print("\t");
      Serial.print("+30 mm to the right");
      Actual_Value = 30;
      break;

Thank you for the help , i now understand the problem better with the pattern matching method. I was however having some issues , last time i had compiled and verified my sketch. I have no issues seeing the output in the serial monitor but the arduino IDE terminal window It seems to complain of CPU reset.

I tried to manually reset the board but the message still persists. I have donwloaded the latest libraries as well. I am not sure why i see this problem ? I tried reinstalling as well.

Sketch uses 34,092 bytes (6%) of program storage space. Maximum is 524,288 bytes.
Atmel SMART device 0x285e0a60 found
Erase flash
done in 0.033 seconds

Write 36376 bytes to flash (143 pages)

[                              ] 0% (0/143 pages)
[==                            ] 9% (14/143 pages)
[=====                         ] 19% (28/143 pages)
[========                      ] 29% (42/143 pages)
[===========                   ] 39% (56/143 pages)
[==============                ] 48% (70/143 pages)
[=================             ] 58% (84/143 pages)
[====================          ] 68% (98/143 pages)
[=======================       ] 78% (112/143 pages)
[==========================    ] 88% (126/143 pages)
[============================= ] 97% (140/143 pages)
[==============================] 100% (143/143 pages)
done in 7.027 seconds

Verify 36376 bytes of flash

[                              ] 0% (0/143 pages)
[==                            ] 9% (14/143 pages)
[=====                         ] 19% (28/143 pages)
[========                      ] 29% (42/143 pages)
[===========                   ] 39% (56/143 pages)
[==============                ] 48% (70/143 pages)
[=================             ] 58% (84/143 pages)
[====================          ] 68% (98/143 pages)
[=======================       ] 78% (112/143 pages)
[==========================    ] 88% (126/143 pages)
[============================= ] 97% (140/143 pages)
[==============================] 100% (143/143 pages)
Verify successful
done in 6.444 seconds
Set boot flash true
CPU reset.

but the arduino IDE terminal window It seems to complain of CPU reset

why do you think so?

I have no detailed knowledge of the Due. I suggest that you post your specific problem in the Due section of the forum.

Thank you for the feedback. It is not an error actually . I wanted to continue on the existing sketch and also wanted to use the analog values in determining the positions. I had thought of using the same principle of Received_Binary in order to process the analog values. I am using the analogRead to read the Voltage which returns a integer value between 0to 1023 on the default Analog resolution setting of 10 bits.
I am not sure what is the problem behind it , perhaps it is that I am not allowed to read out values that way ? The sketch (without the printing of the analog read value) is attached .
Also is it possible to store all the analogRead values in an array and maybe print then out in a text file for different positions ?
I am unable to attach the code here , so i have attached a text file of the sketch.

Arduino_Doubt.txt (8.19 KB)

int analog_values_mapped[15];
// Analog values 

analog_values_mapped[0]=analogRead(A0);
analog_values_mapped[1]=45;
analog_values_mapped[2]=analogRead(A1);
analog_values_mapped[3]=analogRead(A2);
analog_values_mapped[4]=analogRead(A3);
analog_values_mapped[5]=analogRead(A4);
analog_values_mapped[6]=analogRead(A5);
analog_values_mapped[7]=analogRead(A6);
analog_values_mapped[8]=analogRead(A7);
analog_values_mapped[9]=analogRead(A8);
analog_values_mapped[10]=analogRead(A9);
analog_values_mapped[11]=analogRead(A10);
analog_values_mapped[12]=45;
analog_values_mapped[13]=45;
analog_values_mapped[14]=analogRead(A11);

for (int j=0; i<15;i++)
 {

  Serial.println( analog_values_mapped[j]);

  // proceessing and storing the values 

  }

I am not sure what is the problem behind it , perhaps it is that I am not allowed to read out values that way ? The sketch (without the printing of the analog read value) is attached .

I don't understand what problem you are having. You have an array of 15 integer values. What do you want to do with them? Can you please describe in more detail what you want to do with "processing and storing the values"? How many arrays are there? Do you want to store noOfSamples (set to 350 in the current sketch) of the 15 element array.

Also is it possible to store all the analogRead values in an array and maybe print then out in a text file for different positions ?

You may need something different than the Serial monitor of the IDE. A terminal program like RealTerm perhaps, but I'm not sure of what you really want.

Hello
Thank you for the tip about RealTerm

Yes I want to store the noOfsamples 350 of the 15 element array. I would like to do an averaging (first step) so that I get one value from the analog sensors for one corresponding position.

Yes I want to store the noOfsamples 350 of the 15 element array. I would like to do an averaging (first step) so that I get one value from the analog sensors for one corresponding position.

I suggest that you write a small test sketch to sample 3 analog read values 3 times. Once you work out how to create an average the the three values and to place the averages in three different values of an array you can extend it to 350 samples of 15 analog read values.

Hello
Thanks for the feedback. The smaller sketch helps me to understand it much better and i am to move forward in small steps