Having troubles with stopping a function


I am new to Arduino programming, and are testing out some things to see how it works but i have come to a wall i couldnt climb using only the internet(google).

What i am trying to do is to make a basic "menu" system so i can use one arduino to multiple tasks. I was testing it with a photo resistor and a LED, and my intensions was to get the Lightlevel activated with a button, and when i clicked the button again it would turn off the lightlevel function. So i wrote a function, and when i click the button the lightlevel function was working great, but the arduino get stuck in that function and i cant get it to get out of it again. So if anybody could help me with this i would be thankful.

Here is the Main loop:

 void loop(void) 
		int reading = digitalRead(buttonPin);
		if (reading != lastButtonState)
			lastDebounceTime = millis();
		if ((millis() - lastDebounceTime) > debounceDelay)
			if (reading != buttonState)
				buttonState = !sensorState;

				if (buttonState == HIGH)
					sensorState = HIGH;
		if (sensorState == HIGH)
		lastButtonState = reading;

And the function:

	void LightLevel()
		if (sensorState == HIGH)
		photocellReading = analogRead(photocellPin);
		Serial.print("Analog reading = ");
		Serial.println(photocellReading); // the raw analog reading
		// LED gets brighter the darker it is at the sensor
		// that means we have to -invert- the reading from 0-1023 back to 1023-0
		photocellReading = 1023 - photocellReading;
		//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses
		LEDbrightness = map(photocellReading, 0, 1023, 0, 255);
		analogWrite(LEDpin, LEDbrightness);

but the arduino get stuck in that function

Assuming that "LightLevel()" is the function that you sketch got stuck in, then I don't see how that function "sticks.
Post your code.

There’s nothing in your posted code that ever sets SensorState to anything other than HIGH, so once it is, you’ll see the ‘stuckness’ you observe.

Thanks ive got it now, i didnt see that the sensorState was hardcoded to HIGH. Now i can try to add another function to it to see if i could switch between them.