
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

int gasAnalog = A0; int gasDigital = 2; int led = 13; void setup() { pinMode(gasDigital, INPUT); pinMode(led, OUTPUT); Serial.begin(9600); } void loop() { int gasValue = analogRead(gasAnalog); int gasDetected = digitalRead(gasDigital); Serial.print("Gas Value: "); Serial.println(gasValue); if (gasValue > 939) { digitalWrite(led, HIGH); Serial.println("Gas Leakage Detected!"); } else { digitalWrite(led, LOW); Serial.println("Environment Safe"); } delay(500); }