How to set a press button to work once

PLZ someone one help i want to make exucte commande else ony if you press the button once and return to nrml its a sytsem to read GAZ if it it detacte the gaz it run a commande untli you press the button to return to nrml mode

{

digitalWrite(redbulb,LOW);
digitalWrite(greenbulb, HIGH);
digitalWrite(buzzer,LOW);

lcd.setCursor(0, 0);
lcd.print("YOU ARE SAFE !");
lcd.setCursor(7, 1);
lcd.write(byte(1));

ok sorry

Based on the title, look at the state change detection example. The trick is to detect when the button becomes pressed, not when it us pressed.

plz someone help me i want to put a puch button that work only once when the degital anolge read it turn the lighe red and buzr hight but i want to stay like this until you press the button and it return to nrml mode

int analogSensor = analogRead(smokeA0);
while (var < 101) {
delay(30);

static byte percent = 0;

draw_progressbar(percent);

if (++percent == 101) {
lcd.clear();
}

var++;

}

if(smokeA0 < sensorThres)

{
digitalWrite(redbulb, HIGH);
digitalWrite(greenbulb, LOW);
digitalWrite(buzzer,HIGH);

lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("danger !!! gaz");
lcd.setCursor(15, 0);
lcd.write(byte(0));

lcd.setCursor(0, 1);
lcd.print("");

Serial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1 second
Serial.println("AT+CMGS="+"\r"); // Replace x with mobile number
Serial.println("Alerte GAZ");// The SMS text you want to send
Serial.println((char)26);// ASCII code of CTRL+Z for saying the end of sms to the module
Serial.println("ATD+ +;");

delay(50);
}

else

{
digitalWrite(redbulb,LOW);
digitalWrite(greenbulb, HIGH);
digitalWrite(buzzer,LOW);

lcd.setCursor(0, 0);
lcd.print("YOU ARE SAFE !");
lcd.setCursor(7, 1);
lcd.write(byte(1));

delay(50);
}
}

Talk to this guy, but do it quick before he gets a forum timeout.

red1288D

TOPIC MERGED.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum.

Continued cross posting could result in a time out from the forum.

Bob.

yes thnaks sorry about that