Community
cancel
Showing results for 
Search instead for 
Did you mean: 
GS4
Beginner
983 Views

Arduino Program getting hanged after using pulseIn() function.

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.

2 Replies
FTinetti
Honored Contributor I
47 Views

Hi GauthamKS,

There are several threads on this issue (I've not tested them, and I've not used this specific sensor), please take a look and let us know your results:

HTH,

Fernando.

idata
Community Manager
47 Views

Hi GauthamKS,

 

 

Do you have any more questions? Please let me know in order to assist you.

 

 

Have a nice day!

 

 

Best Regards,

 

-Jose
Reply