I need help with my arduino fm radio

Hello I am new to arduino. Im doing a school project. Im having a problem with if statements. They dont print out the stations name when it goes over 88.2MHz on my lcd. Does anyone why this happens?

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <TEA5767Radio.h>

#define CLK 4
#define DT 3
#define SW 2

TEA5767Radio radio = TEA5767Radio();

float counter = 88;
int currentStateCLK;
int lastStateCLK;
byte status = 0;
unsigned long lastButtonPress = 0;

String NizStanica[] = {
  "Radio Dalmacija",        //0
  "HRT HrvatskiRadio1",     //1
  "HRT HrvatskiRadio2",     //2
  "HRT HrvatskiRadio3",     //3
  "HRT RadioSplit",         //4
  "HRT RadioZadar",         //5
  "BHRT BH Radio1",         //6
  "bravo!radio",            //7
  "Narodni radio",          //8
  "Nautic Radio",           //9
  "Radio Sunce",            //10
  "Radio Brac",             //11
  "Federalni radio",        //12
  "Otvoreni radio",         //13
  "Ultra Split",            //14
  "Megamix radioHvar",      //15
  "GradskiRadioTrogir",     //16
  "RadioMarijaVatikan",     //17
  "HrvKatolickiRadio",      //18
  "MirMedugorje",           //19
  "RadioMakarskaRivijera",  //20
  "Jadranski Radio",        //21
};

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  pinMode(CLK, INPUT);
  pinMode(DT, INPUT);
  pinMode(SW, INPUT_PULLUP);
  lastStateCLK = digitalRead(CLK);
  Serial.begin(9600);
  Wire.begin();
  radio.setFrequency(88);
  lcd.backlight();
}
void loop() {
  int i;
  String NazivStanice;
  currentStateCLK = digitalRead(CLK);
  if (currentStateCLK != lastStateCLK && currentStateCLK == 1) {
    if (digitalRead(DT) != currentStateCLK) {
      counter = counter + 0.1;
      if (counter > 108) {
        counter = 87.8;
      }
      radio.setFrequency(counter);
    } else {
      counter = counter - 0.1;
      if (counter < 87.8) {
        counter = 108;
      }
      radio.setFrequency(counter);
    }
    
    if (counter == 87.8) {
      NazivStanice = NizStanica[0];
    }
    if (counter == 88) {
      NazivStanice = NizStanica[1];
    }
    if (counter == 88.1) {
      NazivStanice = NizStanica[6];
    }
    if (counter == 88.4) {
      NazivStanice = NizStanica[4];
    }
    if (counter == 88.8) {
      NazivStanice = NizStanica[3];
    }
    if (counter == 89.3) {
      NazivStanice = NizStanica[1];
    }
    if (counter == 89.7) {
      NazivStanice = NizStanica[1];
    }


    lcd.begin(20, 4);
    lcd.backlight();
    lcd.print(NazivStanice);
    lcd.setCursor(6, 2);
    lcd.print(String(counter, 1) + String("MHz"));
  }
  lastStateCLK = currentStateCLK;
  int btnState = digitalRead(SW);
  if (btnState == LOW) {
    if (millis() - lastButtonPress > 50) {
      Serial.println("Button pressed!");
    }
    lastButtonPress = millis();
  }
  delay(1);
}

Never use an equality test when dealing with floats.
I suggest you keep the frequency as an integer, i.e. 88.9 becomes 889.

Can you explain more what I need to change because every time I try to do something it doesnt work.

I can't see what you've changed, so it's hard for me to say why it doesn't work.

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <TEA5767Radio.h>

#define CLK 4
#define DT 3
#define SW 2

TEA5767Radio radio = TEA5767Radio();

float counter = 88;

int currentStateCLK;
int lastStateCLK;
byte status = 0;
unsigned long lastButtonPress = 0;

String NizStanica[] = {
  "Radio Dalmacija",        //0
  "HRT HrvatskiRadio1",     //1
  "HRT HrvatskiRadio2",     //2
  "HRT HrvatskiRadio3",     //3
  "HRT RadioSplit",         //4
  "HRT RadioZadar",         //5
  "BHRT BH Radio1",         //6
  "bravo!radio",            //7
  "Narodni radio",          //8
  "Nautic Radio",           //9
  "Radio Sunce",            //10
  "Radio Brac",             //11
  "Federalni radio",        //12
  "Otvoreni radio",         //13
  "Ultra Split",            //14
  "Megamix radioHvar",      //15
  "GradskiRadioTrogir",     //16
  "RadioMarijaVatikan",     //17
  "HrvKatolickiRadio",      //18
  "MirMedugorje",           //19
  "RadioMakarskaRivijera",  //20
  "Jadranski Radio",        //21
};

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  pinMode(CLK, INPUT);
  pinMode(DT, INPUT);
  pinMode(SW, INPUT_PULLUP);
  lastStateCLK = digitalRead(CLK);
  Serial.begin(9600);
  Wire.begin();
  radio.setFrequency(88);
  lcd.backlight();
}
void loop() {
  int i;
  String NazivStanice;
  currentStateCLK = digitalRead(CLK);
  if (currentStateCLK != lastStateCLK && currentStateCLK == 1) {
    if (digitalRead(DT) != currentStateCLK) {
      counter = counter + 0.1;
      if (counter > 108) {
        counter = 87.8;
      }
      radio.setFrequency(counter);
    } else {
      counter = counter - 0.1;
      if (counter < 87.8) {
        counter = 108;
      }
      radio.setFrequency(counter);
    }
    int frek = counter * 10;
    if (frek == 878) {
      NazivStanice = NizStanica[0];
    }
    if (frek == 880) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 881) {
      NazivStanice = NizStanica[6];
    }
    if (frek == 884) {
      NazivStanice = NizStanica[4];
    }
    if (frek == 888) {
      NazivStanice = NizStanica[3];
    }
    if (frek == 893) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 897) {
      NazivStanice = NizStanica[1];
    }


    lcd.begin(20, 4);
    lcd.backlight();
    lcd.print(NazivStanice);
    lcd.setCursor(6, 2);
    lcd.print(String(counter, 1) + String("MHz"));
    Serial.print(frek);
  }
  lastStateCLK = currentStateCLK;
  int btnState = digitalRead(SW);
  if (btnState == LOW) {
    if (millis() - lastButtonPress > 50) {
      Serial.println("Button pressed!");
    }
    lastButtonPress = millis();
  }
  delay(1);
}

If you also send that to serial what does it output?

88.1MHz

So is it actually getting up to 88.2+Mhz?

It can go from 87.8 to 108 Mhz and you can hear the stations but problem is the if statements dont print the names of the stations.

I thought I'd suggested not to use floats?

It tried using int but it didnt work because the radio module receiver will try to find frequency of 880Mhz which it cannot find

No, you pass the receiver the value of counter (cast to float) divided by 10.

Arithmetic.

Can you turn the float into int then use it in the if statement

What happens when you try it?

it works but the names shows on 0.1Mhz higher than it should(for example one station is supposed to show up on 88.4 but it shows up on 88.5)

Maybe you made a mistake in the code you didn't post.

its the second code I posted

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <TEA5767Radio.h>

#define CLK 4
#define DT 3
#define SW 2

TEA5767Radio radio = TEA5767Radio();

float counter = 88;

int currentStateCLK;
int lastStateCLK;
byte status = 0;
unsigned long lastButtonPress = 0;

String NizStanica[] = {
  "Radio Dalmacija",        //0
  "HRT HrvatskiRadio1",     //1
  "HRT HrvatskiRadio2",     //2
  "HRT HrvatskiRadio3",     //3
  "HRT RadioSplit",         //4
  "HRT RadioZadar",         //5
  "BHRT BH Radio1",         //6
  "bravo!radio",            //7
  "Narodni radio",          //8
  "Nautic Radio",           //9
  "Radio Sunce",            //10
  "Radio Brac",             //11
  "Federalni radio",        //12
  "Otvoreni radio",         //13
  "Ultra Split",            //14
  "Megamix radioHvar",      //15
  "GradskiRadioTrogir",     //16
  "RadioMarijaVatikan",     //17
  "HrvKatolickiRadio",      //18
  "MirMedugorje",           //19
  "RadioMakarskaRivijera",  //20
  "Jadranski Radio",        //21
};

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  pinMode(CLK, INPUT);
  pinMode(DT, INPUT);
  pinMode(SW, INPUT_PULLUP);
  lastStateCLK = digitalRead(CLK);
  Serial.begin(9600);
  Wire.begin();
  radio.setFrequency(88);
  lcd.backlight();
}
void loop() {
  int i;
  String NazivStanice;
  currentStateCLK = digitalRead(CLK);
  if (currentStateCLK != lastStateCLK && currentStateCLK == 1) {
    if (digitalRead(DT) != currentStateCLK) {
      counter = counter + 0.1;
      if (counter > 108) {
        counter = 87.8;
      }
      radio.setFrequency(counter);
    } else {
      counter = counter - 0.1;
      if (counter < 87.8) {
        counter = 108;
      }
      radio.setFrequency(counter);
    }
    int frek = counter * 10;
    if (frek == 878) {
      NazivStanice = NizStanica[0];
    }
    if (frek == 880) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 881) {
      NazivStanice = NizStanica[6];
    }
    if (frek == 884) {
      NazivStanice = NizStanica[4];
    }
    if (frek == 888) {
      NazivStanice = NizStanica[3];
    }
    if (frek == 893) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 897) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 905) {
      NazivStanice = NizStanica[1];
    }
    if (frek ==902) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 909) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 913) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 918) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 918) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 925) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 928) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 929) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 934) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 936) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 947) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 951) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 956) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 961) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 968) {
      NazivStanice = NizStanica[1];
    }
    if (frek == 972) {
      NazivStanice = NizStanica[1];
    }





    lcd.begin(20, 4);
    lcd.backlight();
    lcd.print(NazivStanice);
    Serial.print(NazivStanice);
    lcd.setCursor(6, 2);
    lcd.print(String(counter, 1) + String("MHz"));
    Serial.print(frek);
    Serial.print(String(counter, 1) + String("MHz"));
  }
  lastStateCLK = currentStateCLK;
  int btnState = digitalRead(SW);
  if (btnState == LOW) {
    if (millis() - lastButtonPress > 50) {
      Serial.println("Button pressed!");
    }
    lastButtonPress = millis();
  }
  delay(1);
}

there is actually a small difference
I added serial print for frequency and Mhz

The second code you posted has counter as a float.

I thought we'd agreed not to do that?

This test version works correctly with floats ->serial monitor

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
//#include <TEA5767Radio.h>

#define CLK 4
#define DT 3
#define SW 2

//TEA5767Radio radio = TEA5767Radio();

float counter = 88;
int currentStateCLK;
int lastStateCLK;
byte status = 0;
unsigned long lastButtonPress = 0;

String NizStanica[] = {
  "Radio Dalmacija",        //0
  "HRT HrvatskiRadio1",     //1
  "HRT HrvatskiRadio2",     //2
  "HRT HrvatskiRadio3",     //3
  "HRT RadioSplit",         //4
  "HRT RadioZadar",         //5
  "BHRT BH Radio1",         //6
  "bravo!radio",            //7
  "Narodni radio",          //8
  "Nautic Radio",           //9
  "Radio Sunce",            //10
  "Radio Brac",             //11
  "Federalni radio",        //12
  "Otvoreni radio",         //13
  "Ultra Split",            //14
  "Megamix radioHvar",      //15
  "GradskiRadioTrogir",     //16
  "RadioMarijaVatikan",     //17
  "HrvKatolickiRadio",      //18
  "MirMedugorje",           //19
  "RadioMakarskaRivijera",  //20 98.4
  "Jadranski Radio",        //21
};

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  pinMode(CLK, INPUT);
  pinMode(DT, INPUT);
  pinMode(SW, INPUT_PULLUP);
  lastStateCLK = digitalRead(CLK);
  Serial.begin(115200);
  Wire.begin();
  //radio.setFrequency(88);
  lcd.backlight();
}
void loop() {
  int i;
  counter = 98.4;//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  String NazivStanice;
  //currentStateCLK = digitalRead(CLK);
  currentStateCLK = 1;//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  if (currentStateCLK != lastStateCLK && currentStateCLK == 1) {
    if (digitalRead(DT) != currentStateCLK) {
      //counter = counter + 0.1;
      if (counter > 108) {
        counter = 87.8;
      }
      //radio.setFrequency(counter);
    } else {
      //counter = counter - 0.1;
      if (counter < 87.8) {
        counter = 108;
      }
      //radio.setFrequency(counter);
    }

    if (counter == 87.8) {
      NazivStanice = NizStanica[0];
    }
    if (counter == 88) {
      NazivStanice = NizStanica[1];
    }
    if (counter == 88.1) {
      NazivStanice = NizStanica[6];
    }
    if (counter == 88.4) {
      NazivStanice = NizStanica[4];
    }
    if (counter == 88.8) {
      NazivStanice = NizStanica[3];
      //NazivStanice = "HRT HrvatskiRadio3";     //3
    }
    if (counter == 89.3) {
      NazivStanice = NizStanica[1];
    }
    if (counter == 89.7) {
      NazivStanice = NizStanica[1];
    }
    if (counter == 98.4) {
      NazivStanice = NizStanica[20];
    }

    lcd.begin(20, 4);
    lcd.backlight();
    lcd.print(NazivStanice);
    Serial.println(NazivStanice);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    lcd.setCursor(6, 2);
    lcd.print(String(counter, 1) + String("MHz"));
  }
  lastStateCLK = currentStateCLK;
  int btnState = digitalRead(SW);
  if (btnState == LOW) {
    if (millis() - lastButtonPress > 50) {
      Serial.println("Button pressed!");
    }
    lastButtonPress = millis();
  }
  delay(1);
}