need som help with a while stament

needed for this is 2 push buttons and 3 LED’s and it is acomponied with code that lets you trie my start setup

but my while stament never seems to go active is there anyone out there that can help me with this?

---------------------------------------------------- Arduino Code-------------------------------------------------------

/* i have tried to document this enough to be used by anyone*/

int inPin = 3;
int inPin2 = 4;
int ledPin = 8;
int ledPin2 = 9;
int ledPin3 = 10;
int val = 0;
int val2 = 0;

int gron; //tried to do this with = 0; to
int gul; //tried to do this with = 0; to
int rod; //tried to do this with = 0; to

void setup()
{
Serial.begin(9600);
pinMode(inPin, INPUT);
pinMode(inPin2, INPUT);
pinMode (ledPin, HIGH);
pinMode (ledPin2, HIGH);
pinMode (ledPin3, HIGH);
gron = 500; // tried without this to
gul = 0; // tried without this to
rod = 500; // tried without this to

}

void loop()
{

//led testing and buton code outcoded but working //
//this code can be used to do the set up if you out code the main code with /* */ .//
//remember to outcode this once the set up is completed //
/*digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin3, LOW);

val = (digitalRead(inPin));
if (val == LOW){
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin2, LOW);
Serial.println(“röd”);
}

val2 = (digitalRead(inPin2));
if (val2 == LOW){
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin, LOW);
Serial.println(“grön”);
}*/

Serial.println(“start”);
delay(1000);
if ( gul < 500 ){Serial.println(“if gul statment”); delay(1000); // cronrols point for gul and should activate the normalt status loop.
while( gul != 500 );{Serial.println(“while gul statment”); delay(1000); // this is a while loop that should take gul to 500 and depending on healing or

getin sicker you should go to the difrenstatuses.
digitalWrite(ledPin2, HIGH);// yellow LED
digitalWrite(ledPin, LOW);// red LED
digitalWrite(ledPin3, LOW); // green LED
val = (digitalRead(inPin));// button one activation controler
if (val == LOW){Serial.println(“if val statment”); delay(1000);// if button one is activ
// Röd red LED, this meens sick
gul = gul + 50;
if(gul == 500){// if this is activated and have a fulfilled statment your geting sick
gron = 500;
rod = 0;
}
}
val2 = (digitalRead(inPin2));// button two activation controler
if (val2 == LOW){Serial.println(“if val2 statment”); delay(1000);// if button one is activ
// Grön gren LED, this meens helthy
gul = gul + 25;
if(gul == 500){ // if this is activated and have a fulfilled statment we get a helthy person
gron = 0;
rod = 500;
}
}
gul = gul++;
Serial.print(gul);
}
if(gul == 500){// if this is activated and have a fulfilled statment your geting sick
gron = 500;
rod = 0;
}
}
delay(250); // delay is not realy used for anything

}

-------------------------------------------------------end----------------------------------------------------------

thanks in advance

while( gul != 500 );{Serial.println("while gul statment"); delay(1000); ... }

The problem here is that the while() should be directly followed by the block not a semi-colon then a block. In C a block is either a single statement of a series or statements in a {} pair. The syntax for a while loop is the while() part followed by a single block. Unfortunatelly for you a ; counts as a statement albeit an empty one. So nix that one ; and you should be fine (other bugs not withstanding).

while( gul != 500 ) {Serial.println("while gul statment"); delay(1000); ... }

Charlieb

yes i saw the fault now been stering for so long at this code so i missed it ^^ thx

Single character bugs are the most annoying kind.

Charlieb