title: Arduino uint8_t variables
body: <p>I'm having trouble with some arduino code. im using an Ethernet tutorial code i found and some IR emitter and receiver code i found, and im trying to combine them. </p>
  
  <p><a href="http://www.ladyada.net/learn/sensors/ir.html" rel="nofollow">http://www.ladyada.net/learn/sensors/ir.html</a></p>
  
  <p><a href="http://g33k.blogspot.com/2010/09/arduino-data-webserver-sample-web.html" rel="nofollow">http://g33k.blogspot.com/2010/09/arduino-data-webserver-sample-web.html</a></p>
  
  <p>Both codes work fine by themselves.</p>
  
  <p>The code compiles but when i call the following void IRDetector() , it doesn't work. I have debugged it and so far ive found when i  use the variable uint8_t or uint16_t (ive tried replacing them with ints and longs). Do i have to import and libraries to use uint8_t ? Any thoughts?</p>
  
  <p>Any help would be appreciated.</p>
  
  <pre><code> uint16_t pulses[100][2];  // pair is high and low pulse 
     uint8_t currentpulse = 0; // index for pulses we're storing
  
      uint8_t highpulse, lowpulse;  // temporary storage timing
  
        void IRDetectCode(void)
     {
      while(true){
  
  highpulse = lowpulse = 0; // start out with no pulse length
  
  while (IRpin_PIN &amp; (1 &lt;&lt; IRpin)) {
    // pin is still HIGH
  
    // count off another few microseconds
    highpulse++;
    delayMicroseconds(RESOLUTION);
  
    // If the pulse is too long, we 'timed out' - either nothing
    // was received or the code is finished, so print what
    // we've grabbed so far, and then reset
    if ((highpulse &gt;= MAXPULSE) &amp;&amp; (currentpulse != 0)) {
       Serial.print(" usec, ");
    //  printpulses();
      //currentpulse=0;
      return;
    }
  }
  // we didn't time out so lets stash the reading
  pulses[currentpulse][0] = highpulse;
  
  // same as above
  while (! (IRpin_PIN &amp; _BV(IRpin))) {
    // pin is still LOW
     Serial.print(" usec, ");
    lowpulse++;
    delayMicroseconds(RESOLUTION);
    if ((lowpulse &gt;= MAXPULSE)  &amp;&amp; (currentpulse != 0)) {
    //  printpulses();
    //  currentpulse=0;
      return;
    }
  }
  //pulses[currentpulse][1] = lowpulse;
  
            // we read one high-low pulse successfully, continue!
         currentpulse++;
    }
      }
  
    void printpulses(void) {
          Serial.println("\n\r\n\rReceived: \n\rOFF \tON");
           for (uint8_t i = 0; i &lt; currentpulse; i++) {
              Serial.print(pulses[i][0] * RESOLUTION, DEC);
              Serial.print(" usec, ");
              Serial.print(pulses[i][1] * RESOLUTION, DEC);
              Serial.println(" usec");
             }
  
           // print it in a 'array' format
       Serial.println("int IRsignal[] = {");
       Serial.println("// ON, OFF (in 10's of microseconds)");
           for (uint8_t i = 0; i &lt; currentpulse-1; i++) {
               Serial.print("\t"); // tab
               Serial.print(pulses[i][1] * RESOLUTION / 10, DEC);
               Serial.print(", ");
              Serial.print(pulses[i+1][0] * RESOLUTION / 10, DEC);
             Serial.println(",");
          }
            Serial.print("\t"); // tab
       Serial.print(pulses[currentpulse-1][1] * RESOLUTION / 10, DEC);
        Serial.print(", 0};");
          }
  </code></pre>