samedi 19 septembre 2015

How to make if condition run once in while(1) loop

Let's consider the following program:

while(1)
{
  if(foo1 == HIGH)
  {
    printf("foo1 is high");
  }
  if(foo2 == HIGH)
  {
    printf("foo2 is high");
  }
}

As these conditions are in while(1) loop, so if foo1 is high printf will keep on printing until foo1 is low & same goes for foo2.

So is there any possible way I can make printf to be displayed once or to make this if condition run once.?

Aucun commentaire:

Enregistrer un commentaire