title: Using an array to store pin bits
body: <p>Just trying to make sure I'm on the correct track here. I'm trying to store lots of 6-bit bytes into an array to control a parallel device with my PIC18F2550.</p>
  
  <p>My array:</p>
  
  <pre><code>char pins[4] = {
          000000, //0
          000001, //1
          000010, //2
          000011, //3
          000100 //4
  }
  </code></pre>
  
  <p>Later in my code, I want to be able to enter a command such as 
  "Set 3" which will set pins RB0-RB5 to 000011 respectively.</p>
  
  <p>PSEUDO CODE:</p>
  
  <pre><code>if command="Set 3" then find pins[3]{
  LATBbits.LATB0 = pins[3][0];
  LATBbits.LATB1 = pins[3][1];
  LATBbits.LATB2 = pins[3][2];
  LATBbits.LATB3 = pins[3][3];
  LATBbits.LATB4 = pins[3][4];
  LATBbits.LATB5 = pins[3][5];
  }
  </code></pre>
  
  <p>which will give:</p>
  
  <pre><code>{
   LATBbits.LATB0 = 0;
   LATBbits.LATB1 = 0;
   LATBbits.LATB2 = 0;
   LATBbits.LATB3 = 0;
   LATBbits.LATB4 = 1;
   LATBbits.LATB5 = 1;
  }
  </code></pre>
  
  <p>Is this an appropriate way to create this? Am I on the right track? Do you have suggestions on a better way to create an efficient array to control a 6bit parallel device with many settings?</p>
  
  <p>Thanks everyone!</p>