AnsweredAssumed Answered

[Solved] How can I use the Arduino microseconds delay of SPC-560P?

Question asked by la_manna.gianluca on Jun 29, 2015
Latest reply on Jul 2, 2015 by Erwan Y
I have this sensor HY-SRF05 with 5 pins. In Arduino using the function delayMicroseconds () to manage the operation of the sensor so:

Arduino code:
01./*
02.Tested with HY-SRF05, HC-SR04
03.Assuming a room temp of 20 degrees centigrade
04.The circuit:
05.    * VVC connection of the sensor attached to +5V
06.    * GND connection of the sensor attached to ground
07.    * TRIG connection of the sensor attached to digital pin 12
08.        * ECHO connection of the sensor attached to digital pin 13
09.*/
10.  
11.const int TRIG_PIN = 12;
12.const int ECHO_PIN = 13;
13.  
14.void setup() {
15.  // initialize serial communication:
16.  Serial.begin(9600);
17.  
18.  pinMode(TRIG_PIN,OUTPUT);
19.  pinMode(ECHO_PIN,INPUT);
20.}
21.  
22.void loop()
23.{
24.   long duration, distanceCm, distanceIn;
25.  
26.  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
27.  digitalWrite(TRIG_PIN, LOW);
28.  delayMicroseconds(2);
29.  digitalWrite(TRIG_PIN, HIGH);
30.  delayMicroseconds(10);
31.  digitalWrite(TRIG_PIN, LOW);
32.  duration = pulseIn(ECHO_PIN,HIGH);
33.  
34.  // convert the time into a distance
35.  distanceCm = duration / 29.1 / 2 ;
36.  distanceIn = duration / 74 / 2;
37.  
38.  if (distanceCm <= 0){
39.    Serial.println("Out of range");
40.  }
41.  else {
42.    Serial.print(distanceIn);
43.    Serial.print("in, ");
44.    Serial.print(distanceCm);
45.    Serial.print("cm");
46.    Serial.println();
47.  }
48.  delay(1000);
49.}



  Of SPC560P how can I do? The board does not handle microseconds.

     Best regards
          Gianluca.

Outcomes