0% found this document useful (0 votes)
25 views

Coding Arduino

The document defines variables for an LCD screen, gas sensor, LEDs, and speaker. It sets up the LCD to display text and the pins for input and output. The main loop reads the gas sensor and displays/plays output based on the sensor reading.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Coding Arduino

The document defines variables for an LCD screen, gas sensor, LEDs, and speaker. It sets up the LCD to display text and the pins for input and output. The main loop reads the gas sensor and displays/plays output based on the sensor reading.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#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("Aminatussaadah");

lcd.setCursor(4,3);

lcd.print("Elektronika Digital");

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