#include <TinyLiquidCrystal_I2C.h>
TinyLiquidCrystal_I2C lcd(0x27,20,4);
#define BUTTON_PIN PB3
#define BUTTON_PIN PB1
int numberfreq;
int count;
float freq = 87.00;
void setup()
{
lcd.init();
// Print a message to the LCD.
lcd.backlight();
pinMode(PB3, INPUT_PULLUP);
pinMode(PB1, INPUT_PULLUP);
lcd.setCursor(0,0);
lcd.print("FM");
lcd.setCursor(3,0);
lcd.print(freq);
lcd.print(" MHz ");
}
void loop()
{
if (digitalRead(PB3) == LOW) {
numberfreq += 1;
delay(200);
if (numberfreq >= 84){
numberfreq = 0;
}
freq = ((numberfreq * 25)+8700)*0.01;
lcd.setCursor(3,0);
lcd.print(freq);
lcd.print(" MHz ");
}
if (digitalRead(PB1) == LOW) {
numberfreq -= 1;
delay(200);
if (numberfreq <= 0){
numberfreq = 84;
}
freq = ((numberfreq * 25)+8700)*0.01;
lcd.setCursor(3,0);
lcd.print(freq);
lcd.print(" MHz ");
}
}