Coding dapat dilihat disini:
//******************************************************************************** //========Detektor Kebocoran Gas LPG Sebagai Antisipasi Sistem Keamanan==********* //******************************************************************************** //********************************Alkhairunas Riyuska***************************** //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- int Buzzer = 2; int SensorMQ2 = A2; int BatasSensor = 200; void setup() { pinMode(Buzzer, OUTPUT); pinMode(SensorMQ2, INPUT); Serial.begin(9600); } void loop() { int analogSensor = analogRead(SensorMQ2); Serial.print("Pin A2: "); Serial.println(analogSensor); if (analogSensor > BatasSensor) { for(int i=1; i<=10; i++){ digitalWrite(Buzzer, HIGH); delay(500); digitalWrite(Buzzer, LOW); delay(500); } }else { noTone(Buzzer); } delay(100); }
0 Komentar