analog interference with sparkfun fm receiver shield

Hi, congratulations for the forum, I found a lot of helpful informations and now I decided to create a profile.

I'm new to the arduino using. I'm trying to make an fm radio with arduino uno. I've already assembled all the hardware parts (amplificators, speakers etc.). So, over the programming of the receiver (I've used part of the example program, and It's working) I need to read 4 analog pins for the use of 4 push button, used for change frequency and set the volume. I only need to get a "analogRead" but when I plug the shield, the analog reading goes crazy and I can't read the correct value (0 or high). I tried with a 10k pull up resistors but it's the same. Has anybody had the same kind of problem?
I ask you for a tip. Thank you so much.

First of all, using an analogRead() to get the status of a button is very "special". Try using one of the digital pins or a digitalRead() on the pin you're currently using and you probably get better results.

Try to get your cabling on a good photo or draw the circuitry so we have an idea how you connected things. Post this and the whole code you're working with.

I managed to read the correct analog value only unplugging the AREF of the fm shield from the arduino board. I had to use pull-up resistors (software) and to change some thresholds in the code, but it works! I couldn't use digital pins because of the shield and the lcd monitor.

Here it is the code. I'm a beginner, if there's something of strange, show me the right way! :slight_smile:

#include <Si4735.h>
Si4735 radio;

int val0 = analogRead(A0);
int val1 = analogRead(A1);
int val2 = analogRead(A2);
int val3 = analogRead(A3);

void setup()
{
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);

digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);

radio.begin(FM);
radio.tuneFrequency(9000);

}

void loop()
{
delay(1000);
analogRead(A0);
val0 = analogRead(A0);

if(val0 < 20)
{

radio.seekDown(); \previous frequency button
delay(1000);
}

analogRead(A1);
val1 = analogRead(A1);
if(val1 < 20)
{

radio.volumeDown(); \volume down button
delay(100);
}

analogRead(A2);
val2 = analogRead(A2);
if(val2 < 20)
{

radio.volumeUp(); \volume up button
delay(100);
}

analogRead(A3);
val3 = analogRead(A3);
if(val3 < 20)
{
radio.seekUp(); \next frequency button
delay(1000);
}

}

Next time you post code, use code tags around it (the hash sign (#) in the editor).

What kind of fm shield are you using? Post a link to the datasheet or product page.

int val0 = analogRead(A0);
  int val1 = analogRead(A1);
  int val2 = analogRead(A2);
  int val3 = analogRead(A3);

is completely useless, it's enough to define the variables:

int val1, val2, val3;

Why are you defining the analog inputs as digital inputs (with internal pull-ups) although you use them as analog inputs?

In your loop() you have several delay() calls. All of them are not necessary. During that delays your Arduino will not react to any button because it's doing nothing, running in a circle. And because of this delays it's doing nothing most of the time. It will be very difficult to push the button at exactly that time it's not doing nothing but reading the button value. Also you should have some state for the button to know when it's pressed and when it's still down from the last press.

So for just one button your code will be like (you have to add the code for the other buttons):

#include <Si4735.h>
Si4735 radio;
byte button0_state = 0;
#define BUTTON0_PIN A0

void setup() {
  pinMode(BUTTON0_PIN, INPUT);
 
  digitalWrite(BUTTON0_PIN, HIGH);
 
  radio.begin(FM);
  radio.tuneFrequency(9000);
   
}

void loop() {
  if (digitalRead(BUTTON0_PIN) == LOW) {
    if (button0_state == 0) {
      button0_state = 1;
      radio.seekDown();
    }
  } else {
    button0_state = 0;
  }
}

The pin of the button is in a define so you can re-define it to any other pin (I would not use an analog pin for such a button as I told already).

Thank you so much!!

this is the fm shield : SI4735 AM & FM Receiver Shield - DEV-10342 - SparkFun Electronics

now i'm going to try to view the frequency on this lcd : http://www.sparkfun.com/products/10168

it will be funny.