0% found this document useful (0 votes)
13 views1 page

Kode Sensor Gas

The document describes an Arduino code for a gas detection system that displays if gas is detected on an LCD, lights an LED and sounds a buzzer accordingly. The code initializes the LCD and pins, then continuously checks a gas sensor pin and updates the LCD and triggers outputs based on the sensor reading.

Uploaded by

Jery Romadhon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Kode Sensor Gas

The document describes an Arduino code for a gas detection system that displays if gas is detected on an LCD, lights an LED and sounds a buzzer accordingly. The code initializes the LCD and pins, then continuously checks a gas sensor pin and updates the LCD and triggers outputs based on the sensor reading.

Uploaded by

Jery Romadhon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <LiquidCrystal.

h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);


int Gas = 7;
int redLed = 6;
int greenLed = 5;
int speaker = 4;

void setup()
{
lcd.begin(20, 4);
lcd.setCursor(0,0);
lcd.print("Gas Detected :");
lcd.setCursor(1,2);
lcd.print("Harianto Andi Matu");
lcd.setCursor(4,3);
lcd.print("Elektronika");
pinMode(Gas , INPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(speaker, OUTPUT);
}

void loop()
{
if(digitalRead(Gas) == HIGH)
{lcd.setCursor(14,0);lcd.print(" Yes");
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
digitalWrite(speaker, HIGH);}

if(digitalRead(Gas) == LOW)
{lcd.setCursor(14,0);lcd.print(" No ");
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(speaker, LOW);}
}

You might also like