Menghubungkan Arduino pro mini Dengan Sensor Ultrasonik (HC-SR04)

Menghubungkan Arduino pro mini Dengan Sensor Ultrasonik (HC-SR04). Oke pemirsa dirumah (anda) kembali lagi bersama saya tidak lain dan tidak bukan adalah admin blog yang super keren ini, siapa sih admin blognya? cari sendiri aja, tp yang jelas bukan anda!!. oke lanjut ke permasalahan daripada nulis yang gak jelas seperti ini,

Masalah : Bagaimana menghubungkan / memasang / membaca / menulis / menggambar / mewarnai sensor jarak / ultrasonik dengan arduino pinjaman !

Solusi :
1. Persiapan alat

  • Musik (jkt48 / ske48 / grup 48 lainnya, selain itu saya jamin anda gagal mengikuti tutorial ini :p)
  • kabel
  • arduino
  • sensor
  • penghubung arduino ke komputer entah namanya apa :v

arduino pro mini sensor jarak ultrasonik

2. Penyambungan dapat dilihat di gambar dibawah ini
arduino pro mini sensor jarak ultrasonik 2

  • vcc sensor dihubungkan dengan vcc arduino
  • begitupula dengan gnd, gnd sensor -> gnd arduino
  • Trig sensor dihubungkan dengan pin arduino nomer 8 (atau sesuai di program)
  • Echo sensor dihubungkan dengan pin arduino nomer 7 (atau sesuai program)

3. Kode Program

dibawah ini adalah contoh program untuk menampilkan jarak sensor ultrasonik melalui serial port.

#define echoPin 7
#define trigPin 8

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop() {
// send a pulse on the trigger pin to initiate measurement
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// the length of the pulse on the echo pin is proportional to the distance
long duration = pulseIn(echoPin, HIGH);
long distance = (duration/2) / 29.1;

if (distance >= 200 || distance <= 0){
Serial.println(“Out of range”);
}
else {
Serial.print(distance);
Serial.println(” cm”);
}
delay(1000);
}

silakan kopi program diatas dan jalankan di arduino IDE

4. Pengujian

arduino pro mini sensor jarak ultrasonik 3 arduino pro mini sensor jarak ultrasonik 4

9 thoughts on “Menghubungkan Arduino pro mini Dengan Sensor Ultrasonik (HC-SR04)

  1. I have been exploring for a little bit for any high quality articles
    or weblog posts in this kind of space . Exploring in Yahoo I eventually stumbled upon this website.

    Studying this info So i’m happy to express that I have a very just right uncanny feeling I came upon just what I needed.
    I so much without a doubt will make certain to do not fail to remember this web site and provides it a look on a relentless basis.

  2. This is the right webpage for anybody who wants to understand this topic.
    You understand so much its almost tough to
    argue with you (not that I really would want to…HaHa).
    You definitely put a new spin on a topic which has been discussed for years.
    Great stuff, just great!

  3. I һaѵe been surfing online more than three hourѕ today, yet I
    neѵer found any interesting articlе like yours. It is pretty worth enough for me.
    In my opinion, if all ԝeb owners and bloggers made good
    content as you did, the net will be a lot more useful than ever before.

Leave a Reply

Your email address will not be published. Required fields are marked *