Commit 93cb0359 authored by joshwinemmanuel's avatar joshwinemmanuel
Browse files


parent 2388a3ca
Pipeline #319281 passed with stage
in 57 seconds
......@@ -220,60 +220,6 @@ void loop() {
<h2 id="Ultrasonic_Sensor">Ultrasonic Sensor<a class="headerlink" href="#Ultrasonic_Sensor" title="Permanent link"></a></h2>
So i used HC-SR04 module amd used the default example code for this sensor.
<div class="codehilite"><pre id="__code_1"><span></span><button class="md-clipboard md-icon" title="Copy to clipboard" data-clipboard-target="#__code_1 > code"></button><code>
// ---------------------------------------------------------------- //
// Arduino Ultrasoninc Sensor HC-SR04
// Re-writed by Arbi Abdul Jabbaar
// Using Arduino IDE 1.8.7
// Using HC-SR04 Module
// Tested on 17 September 2019
// ---------------------------------------------------------------- //
#define echoPin 2 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 3 //attach pin D3 Arduino to pin Trig of HC-SR04
// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
Serial.println("with Arduino UNO R3");
void loop() {
// Clears the trigPin condition
digitalWrite(trigPin, LOW);
// Sets the trigPin HIGH (ACTIVE) for 10 microseconds
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
// Displays the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(" cm");
<video width=100% autoplay="" loop="" muted="" controls="">
<source src="../../Video/Nested Sequence 01.mp4" type=video/mp4>
<h2 id="Joy_Stick">Joy Stick<a class="headerlink" href="#Joy_Stick" title="Permanent link"></a></h2>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment