title: How do I flip specific bits in a specific spot and carry the value to do it again later in the program
body: <p>my plan is to set PORTA= 0x0F thus PORTA= 00001111 and then flipping the signs in PORTC in the if loop so now PORT C is 00001111 then another if loop saying if PORTC’s 0-3 = 1 then set PORTC7=1 showing as PORTC=10001111</p>
  <pre><code>#include &lt;avr/io.h&gt;
  #ifdef _SIMULATE_
  #include &quot;simAVRHeader.h&quot;
  #endif
  
  int main(void) {
      DDRA = 0x00; PORTA = 0xFF; // Configure port A's 8 pins as inputs
      DDRC = 0xFF; PORTC = 0x00; // Configure port C's 8 pins as outputs, initialize to 0s
      while (1)
  {
  
  
      if(!(PINA &amp; 0x01)){
          PORTC |= 0x01;
      }
      if(!(PINA &amp; 0x02)){
          PORTC |= 0x02;
      }
      if(!(PINA &amp; 0x04)){
          PORTC |= 0x04;
          }
      if(!(PINA &amp; 0x08)){
          PORTC |= 0x08;
          }
  
      if(PORTC==0x0F)
      {
          PORTC |= 0x80;
      }
      
  
  }
  
  return 0;
  }
  </code></pre>