Translate

ARDUINO ALAT MONITOR JARAK DAN KECEPATAN MULTIPLE SENSOR HB100 DAN HC-SRF04 VIA BLUETOOTH INTERFACE HANDPHONE ANDROID

ARDUINO ALAT MONITOR JARAK DAN KECEPATAN MULTIPLE SENSOR HB100 DAN HC-SRF04 via BLUETOOTH INTERFACE HANDPHONE ANDROID


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memantau kecepatan dan jarak menggunakan sensor HB100 dan HC-SRF04. alat ini menggunakan interface handphone android. jadi ada dua data yang dikirimkan dari arduino ke handphone android via bluetooth. untuk lebih jelasnya berikut adalah komponen dan programnya. 




a. Arduino Uno




b. Sensor Kecepatan HB100




c. Sensor Jarak HC-SRF04




d. Modul Bluetooth HC-05






e. Program Arduino IDE

 // Frequency input pin: 8 for ARDUINO UNO. Connect the IF pin from the preamp
 // Frequency input pin: 49 for ARDUINO MEGA. Connect the IF pin from the preamp

#include <FreqMeasure.h>
#define trigPin 2
#define echoPin 3

long duration, distance;
int buzzer = 11;
float frequency;
int freq;

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

double sum=0;
int count=0;

void loop() {
  if (FreqMeasure.available()) {
    // average 30 readings together
    sum = sum + FreqMeasure.read();
    count = count + 1;
    if (count > 30) {
       frequency = FreqMeasure.countToFrequency(sum / count);
      float spd = frequency / 19.49; //conversion from frequency to kilometers per hour
      //to improve speed, we update only the bottom row of the LCD
//      Serial.print("F= ");
//      Serial.print(frequency);
//      Serial.print("Hz ");
//      Serial.print("SPD= ");
//      Serial.print(spd);
//      Serial.println("km/h");
 
  freq = frequency;
 
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  Serial.print("Hasil|");
  Serial.print(frequency);
  Serial.print("|");
  Serial.println(distance);
 
  sum = 0;
  count = 0;

    }
  }
 
 
  if((freq <= 5) && (distance <= 10))
  {
  digitalWrite(buzzer, HIGH);
  }
 
  else if((freq > 10)&&(freq < 20) && (distance > 10) && (distance < 20))
  {
  digitalWrite(buzzer, HIGH);
  delay(200);
  digitalWrite(buzzer, LOW);
  delay(200);
  }
 
  else if((freq >= 20) && (distance >= 20))
  {
  digitalWrite(buzzer, LOW);
  }
 
  else
 
  {
  digitalWrite(buzzer, LOW);
  }
 
 delay(300);
}





f. Program Android









g. VIDEO HASILNYA










No comments:

Post a Comment