How to reset inside void function?

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

void Sensor_buzzer (){
static uint8_t i=0;

if (Check_Gas_Voltage(Sensor1)){        // expression 1

if (i==0){                                           // expression 2

_delay_ms(300);           
i++;
}

else if (i>0){                                   // expression 3

Buzzer_Tune();
Sensor_relay_mechanism();

}

else{ i=0;};

_delay_ms(50);

}

I am going to do that (expression 2) runs one time during the gas leakage and reset. If gas leaks continously, it should be first time delay 3 seconds and making a sound. If gas leaks less than 3 seconds, it should be reset void function (start from (expression 1)).
The problem is that if gas leaks less than 3 seconds, it will making a sound one time. How to solve this problem?

sadf

Last Edited: Sat. Jan 12, 2019 - 06:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Stick with your other thread on this:

 

https://www.avrfreaks.net/commen...

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

Topic locked