how can " stop " void loop (switch case ) ....

Dear friends ,
hello
im working on arduino mega 2560 /
i write a sketch ,but
it don’t stop …i want stop after every case.
here is sketch …
also have schematic

#define a1 13
#define b1 12
#define c1 11
#define d1 10

int T1=0;
byte Aumenta=5, Disminuir=4, Reset=3;
boolean aux1=true, aux2=true, aux3=true;

void setup()
{
pinMode(a1,OUTPUT);
pinMode(b1,OUTPUT);
pinMode(c1,OUTPUT);
pinMode(d1,OUTPUT);
BCD(0,d1,c1,b1,a1); 

pinMode(53,OUTPUT);// clutch

pinMode(52,OUTPUT);// selector


}

void loop()
{
if(digitalRead(Aumenta)==HIGH && aux1==true) //Codigo para aumentar 
   {
     aux1=false;
     T1++;         
     if(T1>5){ T1=0;}

     
          
   }
if(digitalRead(Aumenta)==LOW && aux1==false){aux1=true;}
   

if(digitalRead(Disminuir)==HIGH && aux2==true) //Codigo para disminuir 
   {
     aux2=false;
     T1--;         
     if(T1<0){ T1=5;}
     
   }
if(digitalRead(Disminuir)==LOW && aux2==false){aux2=true;}
 
   
if(digitalRead(Reset)==HIGH && aux3==true) //Codigo para resetear
   {
   aux3=false;
   T1=0;
       
   }            
if(digitalRead(Reset)==LOW && aux3==false){aux3=true;}    

     BCD(T1,d1,c1,b1,a1); 
       
}


void BCD(byte Contador, byte D, byte C, byte B, byte A)

{
switch(Contador)
{
case 0: digitalWrite(D,LOW);digitalWrite(C,LOW);digitalWrite(B,LOW);digitalWrite(A,LOW);

       break; 

     
case 1: digitalWrite(D,LOW);digitalWrite(C,LOW);digitalWrite(B,LOW);digitalWrite(A,HIGH); 
     
     


[color=red]digitalWrite(53,HIGH);
 delay(100);
 digitalWrite(53,LOW);

 digitalWrite(52,HIGH);
 delay(100);
 digitalWrite(52,LOW);

[color=red][here i mean , this part never stop.how can i stop this process .and start another process  case2] [/color]                                                           
[/color]

break;


case 2: digitalWrite(D,LOW);digitalWrite(C,LOW);digitalWrite(B,HIGH);digitalWrite(A,LOW);

digitalWrite(53,HIGH);
delay(100);
digitalWrite(53,LOW);

digitalWrite(52,HIGH);
delay(100);
digitalWrite(52,LOW);


       break;
       }

Hi,
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

You have already posted 19 contributions.
So, why can’t you read and follow the basic rules of this forum and put your code in between code tags </> ?

Pls do so and then you will get answers.

What do you mean by “stop”?

A dead-stop, nothing else happens until reset?

A pause? How long?

i dont want it Repeat itself ...i want it break and wait,, untill case 2 happen
break untill case 2 happen ,
then ,break untill case 3 .
and ....
i dont want freeze program
case 1: digitalWrite(D,LOW);digitalWrite(C,LOW);digitalWrite(B,LOW);digitalWrite(A,HIGH);

digitalWrite(53,HIGH);
  delay(100);
  digitalWrite(53,LOW);

  digitalWrite(52,HIGH);
  delay(100);
  digitalWrite(52,LOW);

this part ,,Repeat it self
and never break ... i want break it ,untill case2

If I'm reading your code correctly (and it's not easy to read), you call "BCD" every cycle of loop().
If you want it to stop, don't call it every cycle of loop().

As learned in your first post, pls use the code tags also for posting fragments of code, even when the portion is small. Thanks.

AWOL:
If I'm reading your code correctly (and it's not easy to read), you call "BCD" every cycle of loop().
If you want it to stop, don't call it every cycle of loop().

thank you
can you write an example .let me know who to do it ...
how
don't call "BCD" every cycle of loop().

IMHO you need to design your program differently. Have a look at Planning and Implementing a Program

...R

here is schematic

Image from Reply #9 so we don’t have to download it. See this Image Guide

0b2fd39690ba32766d3f68b8ee11d28c33ae01c0.jpg

…R