title: Ultrasonic Sensor in AVR
body: <p>I am working on creating an ultrasonic range detector.  I am currently testing the sensor to make sure that it is functioning properly.  I have connected the echo pin and trigger pin to PC4 and PC5 respectively.  When I run this code, ideally it would send 6 to my display.  However, it is displaying 0.  This leads me to believe that code is not properly interfacing with the sensor.  Please help.</p>
  
  <pre><code>#define F_CPU 16000000UL
  
  #include &lt;avr/io.h&gt;
  #include &lt;util/delay.h&gt;
  #include &lt;avr/interrupt.h&gt;
  
  void DisplayIt(int i);
  
  int main(void)
  {
  
      while(1)
      {
          DDRC = 0xFF;
          int i = 0;
          PORTC = 0b00000000;
          _delay_us(2);
          PORTC = 0b00100000;
          _delay_us(10);
          PORTC = 0x00;
  
          DDRC = 0x00;
          if (PINC == 0b00010000)
          {
              i = 6;
          }
          DisplayIt(i);
      }
  
  }
  </code></pre>