"DO" " While" Problem


i can not loop in statement stop when when condition in "while" condition met can assist please.


int pin0 =0;  
int pin1 =1;
int pin2 = 2;
int pin8 =8;
int pin9 = 9;
int pin10 = 10;
int pin11 = 11;
int pin12 = 12;
int pin13 = 13;
int a=0;
int b=0;
int c=0;
int z = 0;
int val0;
int val1  ;
int val2 ;
//========================
void setup()
{
 pinmode(pin0, input);
 pinmode (pin1, input);
 pinmode (pin2, input);
 pinmode (pin8, output);
 pinmode (pin9 , output);
 pinmode (pin10, output);
  pinmode (pin11, output);
   pinmode (pin12, output);
   pinmode (pin13, output);
serial.begin(9600);
}
//---------------------------------------------------------
void loop()
{

val0 =   digitalread(pin0);
val1 =   digitalread(pin1);
 val2 =   digitalread(pin2);
// digitalwrite(pin10, low);
//  digitalwrite(pin8, low);

  if (val0 ==low) {    // when pin0 low z reset zero
  ( z=0);
  (c=0);
  (digitalwrite(pin9, high)) ;}
 (digitalwrite(pin8,low ));


 if  ((val0 == high )&& (z==0)){      // when pin0 high alarm set , count down commences
   (digitalwrite(pin8, high));
(digitalwrite(pin9, low));
   
 for (int = 0; <=20; a++)
 delay (1000);
  (z=20);
 (b = 0);
}




// serial.print (z);  

 if  ((  val2  == low) && ( z == 20)) {   (digitalwrite(pin9, low));  // when intrusion pin 2 goes low , count down completed alarm sequencing commences.


{
(c==0);
 ( b== 0)  ;

if ((b > 5) && (b < 15)) (digitalwrite(pin10, high));  // 5 count time before stop alarm

delay (1000 );

 if   ((b > 15)&& (b <20))  (digitalwrite(pin10, low));  // alarm off 5 count
 if (b == 20){(c= c+1); (b=0);}  // resets b 0 , counts c one
 serial.print (b);
 b=b+1;
 }

while ((val0 == high)||(c < 3)) ;   // if either pin 0 goes high or loop completes 3 cycles 'do' cycle cease.
(digitalwrite(pin13, high));  

   }  
}

code: [select]
c==0;
b== 0;


these 2 lines test equality, not set variable 0 - use single equal sign that.


if format code braces line matching left brace { ,  right brace } in same columns easer see scope of  the statement.

to maintain formatting, please post code using code blocks (the # icon in forum editor)


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > "DO" " While" Problem


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums