2 Replies Latest reply on Jan 31, 2017 12:28 PM by Intel Corporation

    Arduino Program getting hanged after using pulseIn() function.

    GauthamKS

      I am using Intel Galileo Gen2 Board to display the distance measured by HC-SR04 ultrasonic module. I used the following code:

      [Code]

      const int TrigPin = 8;

      const int EchoPin = 9;

       

       

      float dist;

       

       

       

       

      void setup()

      {

        Serial.begin(9600);

        pinMode(13,OUTPUT_FAST);

        pinMode(TrigPin, OUTPUT_FAST);

        pinMode(EchoPin, INPUT_FAST);

      }

       

      void loop()

      {

       

        fastDigitalWrite(TrigPin, LOW);

        delayMicroseconds(2);

        fastDigitalWrite(TrigPin, HIGH);

        delayMicroseconds(10);

        fastDigitalWrite(TrigPin, LOW);

        dist =pulseIn(EchoPin, HIGH,5000) / 58.0;

       

        Serial.print(dist);

        Serial.println(" cm");

        delay(100);

       

        digitalWrite(13,HIGH);

        delay(100);

        digitalWrite(13,LOW);

        //resetFunc();

      }

      [Code]@

       

      The output is getting hanged after few readings. Any Suggestions? If I reprogram the process repeats.SerialOut.png