Potentiometer tuning of FM receiver based on SI 4703

Hello there !

I would like to ask for your help. I am currently trying to build FM receiver and my requirement is using potentiometer for tuning. Currently I can switch between 10 preset frequencies (that are written in my code), but after turning potentiometer, I have to press the button to switch to required station.

So my goal is to remove button from the process of tuning, with only using potentiometer to switch between stations.

Thanks for your help

Hardware:
Arduino Uno, SI4703 (3,3V, GND, SDA, SCL, RST-pin D2), potentiometer attached to pin A1, pushbutton to pin D6.

#include <Arduino.h>
#include <Wire.h>
#include <radio.h>
#include <si4703.h>

// ----- Fixed settings here. -----

#define FIX_BAND     RADIO_BAND_FM   ///< The band that will be tuned by this sketch is FM.
//#define FIX_STATION  8930            ///< The station that will be tuned by this sketch is 89.30 MHz.
#define FIX_VOLUME   4               ///< The volume that will be set by this sketch is level 4.

int potPin = A1;
int backButton = 6;

SI4703 radio;    // Create an instance of Class for Si4703 Chip
int stations[12] = {8770,9080,9140,9660,10030,10520,10010,10280,10400,10480,10640,10710};
/// Setup a FM only radio configuration
/// with some debugging on the Serial port
void setup() {
    pinMode(backButton, INPUT);
  // open the Serial port
  Serial.begin(57600);
  //Serial.println("Radio...");
  delay(200);

  // Enable information to the Serial port
  radio.debugEnable();

  // Initialize the Radio 
  radio.init();

  // Set all radio setting to the fixed values.
  radio.setBandFrequency(FIX_BAND, 8770);
  radio.setVolume(FIX_VOLUME);
  radio.setMono(false);
  radio.setMute(false);
} // setup


void loop() {
  if(digitalRead(backButton)==HIGH){
    setFrequency();
  }
}
void setFrequency(){
  float displayStation;
  int stationNum, val;
  radio.setMute(false);
  val = analogRead(potPin);
    stationNum = map(val, 0, 1023, 0, 11);
    displayStation = stations[stationNum]/100.0;
         delay(500);
  radio.setBandFrequency(FIX_BAND, stations[stationNum]);
  radio.setMute(false);
  }

What have you tried and what are the results?
Paul

Since I am not so skilled at Arduino programming, so I just simply replaced HIGH statement for LOW in void loop. This works how I want, but delay(500) interrupts the audio in set 500 ms intervals.

void loop() {
  if(digitalRead(backButton)==LOW){
    setFrequency();
  }
}
void setFrequency(){
  float displayStation;
  int stationNum, val;
  radio.setMute(false);
  val = analogRead(potPin);
    stationNum = map(val, 0, 1023, 0, 11);
    displayStation = stations[stationNum]/100.0;
         delay(500);
  radio.setBandFrequency(FIX_BAND, stations[stationNum]);
  radio.setMute(false);
  }

What happens when you eliminate the delay?
Paul

It is not possible to listen to that. Without the delay whole sound is like constantly switching on and off and you dont even know what station is playing.

lego1234567:
It is not possible to listen to that. Without the delay whole sound is like constantly switching on and off and you dont even know what station is playing.

Then the problem is NOT knowing how the radio chip works, not the Arduino “C” code.
Paul

Can you explain in words what you want ?

A potmeter to a analog input has some noise. So the potmeter could be accepted only when it is turned a certain amount. But then any fine-tuning will not work. So you need some kind of automatic fine-tuning mode. I still don't see that happening, because fine-tuning and the analog noise don't work well together.

Or do you want the potmeter to select the preset radio stations ? Suppose you have 10 radiostations, then you can split the analog value into a number of separate parts to select one of the 10 radiostations. That is possible.

I would keep the button. Use either the preset radio stations or use the potmeter. The button toggles between the two.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.