hi,
I am using the HC-SR04 supersonic module and would like to visualize its output. The signals going out from Trigger! From my understanding and per datasheet it has to look like that: (see attachment)
Now I took the example sketch and deleted/commented out the - in my opinion - unnecessary lines and altered the Serial.println near the end.
const int trigPin = 9;
//const int echoPin = 10;
//float duration, distance;
void setup() {
pinMode(trigPin, OUTPUT);
// pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// duration = pulseIn(echoPin, HIGH);
// distance = (duration*.0343)/2;
// Serial.print("Distance: ");
// Serial.print(distance)
Serial.println(digitalRead(trigPin));
delay(100);
}
But the serial plotter only shows a straight line. See attachment 2.
How can I make the plot look like the signal as shown above?
Thank you!