Making a Spirit box with the TEA5767 radio module

Hey guys n girls, so im trying to build and program a spirit box with the TEA5767 radio chip, and im trying to include a couple functions:

-A potentiometer to adjust the scanning speed

  • A switch button that when on HIGH it will scan upwards, when on LOW it will scan downards through the FM frequencies
  • A button that when on LOW scans through the FM frequencies in a random pattern

This is my code so far:

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


TEA5767Radio radio = TEA5767Radio();
int speedPotPin = A3;
/*

*/

void setup() {
  Wire.begin();
  Serial.begin(9600);
  pinMode(A3, INPUT_PULLUP);
}

void loop()
{
  int Val = analogRead(speedPotPin);
  float potVal = ( Val / 1023.0) * 0.9;

  float minVal = 0.1;
  float maxVal = 1.0;

  int delayVal = (potVal + minVal);

  for (int i = 850 ; i < 1080 ; i++ )
  {
    float freq = i / 10.0 ;
    radio.setFrequency(freq);
    delay(delayVal);
    Serial.println(i);                   // For checking the frequency scan speed
  }
}

At the moment im stuck on getting the potentiometer to work properly, right now it doesnt increase or decrease the scan speed. I think the error is in the delay function and how i’m trying to set it up.

Could someone help me to get this scan speed potentiometer to work properly ?

You have declared the pin A3 as a digital input ( pinMode(A3, INPUT_PULLUP); ). But you want to use it as an analog input...
Take a look at the Arduino reference: analogRead() - Arduino Reference

E40racer:
You have declared the pin A3 as a digital input ( pinMode(A3, INPUT_PULLUP); ). But you want to use it as an analog input...
Take a look at the Arduino reference: analogRead() - Arduino Reference

Ok i have updated the code, i've changed the delay value in the for loop, changed the value from delayVal ( which it doesnt seem to be able to use ?? ) to just Val, now the potentiometer does actually work, but the scan speed increase only applies after i reset the arduino ?

Delay will only take an unsigned long value, not a float. delay() - Arduino Reference

CanniBull33:
Ok i have updated the code

...but not posted it.

AWOL:
…but not posted it.

Code is on its way im editing it so ive got everything set up correctly

Okay i cant get it to work, current code is

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

TEA5767Radio radio = TEA5767Radio();
int speedPotPin= A3;
/*

*/

void setup() {
  Wire.begin();
  Serial.begin(9600);
}

void loop() 
{
  int value = analogRead(A3);
  float potRatio = (value / 1023.0) * 0.9;
  
  float minVal = 0.1;
  float maxVal = 1.0;
  
  float delayVal = (potRatio + minVal);
  
  
  for (int i = 850 ; i < 1080 ; i++ )
  {
    float freq = i/10.0 ;
    radio.setFrequency(freq);
    Serial.println(potRatio);
  }
}

How do i get the

 float potRatio = (value / 1023.0) * 0.9;
  
  float minVal = 0.1;
  float maxVal = 1.0;
  
  float delayVal = (potRatio + minVal);

portion of the code to fit into the unsigned long format so it works for delay ?