2 Replies Latest reply on May 13, 2015 11:15 AM by Intel_Peter

    Galileo to drive ultrasonic module?Failed!!Need help.


      Hi,I am a fresh Galileo User.

      Here is the ultrasonic module named "HC-SR04".

      It has 4 pins identified as Vcc,Trig,Echo,Gnd in sequence.

      I tried to drive the module in the same program as below.


      here is the list of my code below.


      const int trig_pin = 8; // trig pin connects to Galileo Board Pin 8;

      const int echo_pin = 9;//echo pin connects to Galileo Board 9;


      void setup(void)







      void loop(void)


           digitalWrite(trig_pin,LOW); to set the trig pin to low at first;





      the trig pin is set to low at first,then it is pulled up yo high and lasts at least 10us.this is the signal that the compent will regard as the beginning signal.

      and it will start a ultrasonic to explore.and the echo pin will recieve the feedback when sth. get in the way while the ultrasonic signal is spreading.

      then the echo pin will start a HIGH level signal.That's way I set the echo_pin to INPUT;



           float distance = pulseIn(echo_pin,HIGH);//Question:Is the function PulseIn() availible for Galileo???

          distance = distance / 58.0;




      and when the sketch is uploaded, the Serial Monitor always print ZERO!!!!

      I've been trying to solve this problem but recieve no reply.

      Anyone gor good ideas???