SIRINE ARDUINO
- Senin, 18 November 2024
- Elektronika Smk Sanjaya
- Administrator
- 0 komentar
Berikut saya akan simulasikan sirine menggunakan mikrokontroller arduino. perhatikan langkah kerja berikut ini seperti biasa
- Gambar kerja/sketsa
- Buat Diagram alir
- Buat sketsa/koding/program
- verifikasi pada aplikasi arduino/compiled
- Upload
Kebutuhan :
- Buzzer :
- NTC Temperatur
- Arduino UNO dan LED
SKETSA RANGKAIAN :
KODING :
/**
int INTO = 2;
int INTO = 0;
int LED1 = 3;
int LED2 = 4;
int spk = 5;
*/
void setup() {
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
}
void loop() {
if (digitalRead(2) == LOW) {
tone(5, 900);
delay(500);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(1);
tone(5, 800);
delay(500);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
delay(100);
}
else {
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(100);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(100);
}
}