title: Storing serial print data from arduino in array
body: <p>I'm using a bluetooth connection to send serial data from Arduino to my Android app.  The code I'm using to connect the Android device is <code>BluetoothChat.java</code> which is sample code you can find if googled.</p>
  
  <p>The sample code displays the data in a <code>ListView</code> and I want to store it in an array.</p>
  
  <p>Here is the code for reading the serial print from the Arduino...</p>
  
  <pre><code>case MESSAGE_READ:
  
              byte[] readBuf = (byte[]) msg.obj;
              String readMessage = new String(readBuf);
              mConversationArrayAdapter.add(readMessage);
              int a = readBuf.length;
  
              //coordinates[] is the exact length necessary as given by double[a], and contains no more and
              //no fewer positions than required.
  
              double coordinates[] = new double[a];
  
              //Check the values of the data in readBuf[] and make the necessary conversions to store in the
              //variables.
              for(int i=0; i&lt;a; i++){
  
                  int val=readBuf[i];
  
                  /*
                  *(int) val/8 will divide val and round down to the nearest integer.
                  *val%8 divides by 8 but takes the remainder which is the value of
                  *all variables above x1, though the math works with x1.
                  */
  
                  coordinates[(int) val/8] = val%8;
  
              }
  </code></pre>
  
  <p>I think I stored the data correctly.  But when I use <code>coordinates[]</code> it doesn't change the text in the <code>TextView</code> I have setup.  Below is the code to set the text.</p>
  
  <pre><code>if(readBuf.length==4){
                  double x1 = coordinates[0];
                  double x2 = coordinates[1];
                  double y1 = coordinates[2];
                  double y2 = coordinates[3];
  
                  r = new Regression(x1, x2, y1, y2);
                  r.computation();
  
                  leftLung.setText("Left Lung "+ r.leftLungDamage() +"% hit");
                  rightLung.setText("Right Lung "+ r.rightLungDamage() +"% hit");
                  heart.setText("Heart "+ r.heartDamage() +"% hit");
                  liver.setText("Liver "+ r.liverDamage() +"% hit");
                  smallIntestine.setText("Small Intestine "+ r.smIntestineDamage() +"% hit");
                  largeIntestine.setText("Large Intestine "+ r.lgIntestineDamage() +"% hit");
                  stomach.setText("Stomach "+ r.stomachDamage() +"% hit");
                  spleen.setText("Spleen "+ r.spleenDamage() +"% hit");
                  gallbladder.setText("Gallbladder "+ r.gallbladderDamage() +"% hit");
                  lKidney.setText("Left Kidney "+ r.lKidneyDamage() +"% hit");
                  rKidney.setText("Right Kidney "+ r.rKidneyDamage() +"% hit");
                  pancreas.setText("Pancreas "+ r.pancreasDamage() +"% hit");
                  venaCava.setText("Vena Cava "+ r.venaCavaDamage() +"% hit");
                  dAorta.setText("Descending Aorta "+ r.dAortaDamage() +"% hit");
                  aAorta.setText("Ascending Aorta "+ r.aAortaDamage() +"% hit");
              }
  </code></pre>
  
  <p>Regression works on its own as a standalone Java application.</p>