Modul 1 Jarak dan suara


Percobaan IV

Keypad dan LCD

1. Foto Hardware dan Diagram Blok [Kembali]


Diagram Blok:


2. Prosedur Percobaan  [Kembali]

Rangkai semua komponen 
+ buat program di aplikasi arduino IDE
+ setelah selesai masukkan program ke arduino 
+ jalankan program pada simulasi dan cobakan dengan modul




Prinsip Kerja:
Inputan masuk dari sensor jarak ( Ultrasonik ) dengan jara tertentu maka speaker akan hidup

kondisi pertama 
dibawah 500 cm tidak hidup speaker

kondisi kedua
diatas 500 cm hidup

4. Flowchart dan Listing Program [Kembali]


Flowchart:






Listing Program:

int trigPin = 7;
int echoPin = 6;
int buzzerPin = 8; // Define the buzzer pin
int distance, duration;
int buzzerThreshold = 20; // Set the distance threshold for the buzzer to sound, adjust as needed

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzerPin, OUTPUT); // Set the buzzer pin as an output
}

void loop() {
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;

  Serial.print("Jarak objek: ");
  Serial.print(distance);
  Serial.println(" cm");

  if (distance < buzzerThreshold) {
    // If the distance is less than the threshold, play a tone on the buzzer
    tone(buzzerPin, 1000); // You can adjust the frequency as needed
  } else {
    // If the distance is greater than or equal to the threshold, turn off the buzzer
    noTone(buzzerPin);
  }

  delay(500); // You may want to adjust this delay based on your application.
}

5. Kondisi [Kembali]

    -Input dari sensor jarak akan menentukan keluarn dari speaker

᭒ HTML↠ klik disini
᭒ Aplikasi↠ klik disini
Gambar Rangkaian↠ klik disini
Video Percobaan↠ klik disini
᭒ Datasheet 74LS249 (Decoder BCD to Seven Segment) ↠ klik disini

File_keperluan_modul_Jarak dan Suara

Tidak ada komentar:

Posting Komentar

Incubator

[KEMBALI KE MENU SEBELUMNYA] DAFTAR ISI 1. Foto Hardware dan Diagram Blok 2. Prosedur Percobaan 3. Rangkaian Simulasi ...