boolean test(void)
{
if (light==0)
{
return false;
}
;
if ( BIT_IS_SET(PINB, 2) )
{
if ((colour==1 && light==4)||(colour==0 && light==5))
{
mark=mark+100;
light=0;
return true;
}
else
{
life=life-1;
analogWrite(SPEAKERPIN,200);
delay(10);
analogWrite(SPEAKERPIN,0);
light=0;
return true;
}
;
}
delay(10);
if(BIT_IS_SET(PINB, 3))
{
if ((colour==1 && light==5)||(colour==0 && light==4))
{
mark=mark+100;
light=0;
return true;
}
else
{
life=life-1;
analogWrite(SPEAKERPIN,200);
delay(10);
analogWrite(SPEAKERPIN,0);
light=0;
return true;
}
}
return false;
}
void loop()
{
game();
while(test()==false)
{
}
;
if(life<0)
{
die();
}
the test function do not work as i throught,after click the button ,it will direcly go to the die fuction(2->-1).no mather the number of colour and light .when button pressed ,most of the time will make it repeat the test function until it die.