Arduino tempature

Hello i am a neewbie at codeing,

I am trying to make a arduino projekt, where i have a lm35 and a closed cicuit that needs a button to push down(no voltage) for it to work. This is where i need the arduino. but it should only make a connection for like 0,5 sec max.

The problem i am struggling with at the moment is that i need it to send a signal once when it reaches 30 degrees, and then send a signal again when it gets below 30 degrees.

The code so far

float temp;
int tempPin = A0;
int led_pin=13;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led_pin,OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
temp = analogRead(tempPin);

temp = temp * 0.48828125;
Serial.print(temp);
Serial.println();

do{
digitalWrite(led_pin,HIGH);
delay(500);
digitalWrite(led_pin,LOW);
}
while(temp < 30 & temp > 29);

}

at the moment i have a led instead of the circuit just for test purposes.

Please help me with this project

First, lets establish that your circuit follows page 15 of the LM35 datasheet, Basic Centigrade Temperature Sensor. Next, if I understand correctly, you want to watch the temperature continuously, and trigger a signal when it crosses the 30 degree centigrade threshold, either rising or falling. This signal is triggers at the cross, only once... Does that mean for the LED you want it to light momentarily, say 100 milliseconds? I will suggest than unless you NEED to report the temperature value in human readable terms, no conversion to actual centigrade is needed. Also, if you do, you do not need to use float variables as analogRead() will return a positive value from 0-1023, 1024 possible temperatures, all positive, so conversion to include a decimal can be done with a sprint() statement and will not require a 32-bit global register.

const int ThresholdValue = 280;// 0 mV + 10.0 mV/°C @ 30°C = 300 mV; analogRead(LM35Pin) == 19 @ 2.041016°C; analogRead(LM35Pin) == 280 @ 30.07813°C; analogRead(LM35Pin) == 1023 @ 109.8926°C;
const byte LM35Pin = 14;
const byte LEDPin = LED_BUILTIN;
unsigned long ledTimestamp;

void setup() {
  // put your setup code here, to run once:
  analogReference(INTERNAL);
  pinMode(LEDPin, OUTPUT);
  digitalWrite(LEDPin, LOW);
}

void loop() {
  if (crossTemp()) blinkLED();
  if (millis() - ledTimestamp >= 100UL) digitalWrite(LEDPin, LOW);
}

bool crossTemp() {
  static int previousTemp = 0;
  int currentTemp = analogRead(LM35Pin);
  bool b = false;
  if ((previousTemp < ThresholdValue  && currentTemp >= ThresholdValue) || (previousTemp > ThresholdValue && currentTemp <= ThresholdValue)) b = true;
  previousTemp = currentTemp;
  return b;
}

void blinkLED() {
  digitalWrite(LEDPin, HIGH);// turn LED on
  ledTimestamp = millis();
}
while(temp < 30 & temp > 29);   // This is a bitwise AND which will TOTALLY foul things up!
while(temp < 30) && (temp > 29));  //This a logical AND which is what you want