title: Line follower robot using atmega8
body: <p>I Am new to AVR programming. I am trying to build a Line follower robot using atmega8 which can park itself when both the infrared sensors detect black . my sensors are connected to the <code>PORTD2</code> and <code>PORTD3</code>, and my Motors are connected to <code>PORTB0</code> and <code>PORTB4</code> . I planned on running and then delaying the motor for 3 second and the switching them off but the robot has started to work haphazardly. Please help me find out what is wrong with my code.</p>
  
  <pre><code>#include&lt;avr/io.h&gt;
  #include&lt;util/delay.h&gt;
  int main()
  {
      DDRD=0b00000000;
      DDRB=0b11111111;
      uint8_t sensor;
      uint8_t A= 0b00000000;
      while(1)
      {
          A=0b00000000;
          sensor = PIND;
          A= sensor|0b11110011;
          switch(A)
          {
          case 0b11110011:
              PORTB=0b00010001;
              _delay_ms(3000);
              PORTB=0b00000000;
              break;
          case 0b11111011:
              PORTB=0b00000001;
              break;
          case 0b11110111:
              PORTB=0b00010000;
              break;
          case 0b11111111:
              PORTB=0b00010001;
              break;
          }
      }
      return 0;
  } 
  </code></pre>