Activating LED with Thermistor Input

I’m a high school student working on a project for an engineering class, and I’ve been having some issues getting my code to work how I intend. I’m using a thermistor as an input in the A0 pin, and I’m trying to output to an LED in the 13 pin. My goal is to cause the LED to flash if the thermistor has less than 0.5 or 1.0 volts going through it, otherwise have the LED be off. This isn’t going as well as I’d like, unfortunately. Rather than the what I would like to happen, the LED is just flashing on and off. I have little idea of what is wrong, and would like some help. My code is as follows, thank you.

int ledPin = 13;
int inPin =A0;
int voltState = 0;
void setup(){
 pinMode (inPin, INPUT);
 pinMode (ledPin, OUTPUT);
}

void loop() {
  int sensorValue = analogRead(inPin);
  float voltState = sensorValue * (5.0 / 1023.0);
  
  if (voltState > 1.0);
  if (voltState < 0.5) {
   loop();
   digitalWrite(ledPin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(ledPin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000); 
}
else{
  digitalWrite(ledPin, LOW);
}
}
  float voltState = sensorValue * (5.0 / 1023.0);

Instead of wasting resources turning the floating point into voltage and comparing the voltage. Spend a few minutes doing some simple algebra and determing the sensorValue for which voltState is equal to 0.5 and 1.0, and just comparing sensorValue to those values.

if (voltState > 1.0);
if (voltState < 0.5) {
   loop();

What do you think this is doing? Hint: It’s not.

Arrch:

if (voltState > 1.0);

if (voltState < 0.5) {
  loop();




What do you think this is doing? Hint: It's not.

I’m trying to make it so if the voltage is higher than 1 OR less than < 0.5, the LED activates.

Frahnkenshteen:
I’m trying to make it so if the voltage is higher than 1 OR less than < 0.5, the LED activates.

So you want an if statement for 1 condition or the other:

if (condition1 || condition2)
{
  // code here
}

What do you think this is doing? Hint: It's not.

Calling loop() from loop() is a really bad idea. In general, it means that you haven't understood and accepted that loop() is already called in an infinite loop, and doesn't need your help to be called again.