Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9877 Discussions

Arduino Program getting hanged after using pulseIn() function.

GS4
Beginner
1,082 Views

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
146 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
146 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