Need help added something to a spirit box build

Programming Questions would love to add some more white noise to this code or add some default frequencies

Here what i have


#include <Wire.h>
#include <TEA5767.h>
#include <LiquidCrystal.h>


LiquidCrystal lcd( 8,  9,  4,  5,  6,  7);
TEA5767 radio = TEA5767();    // Creates the radio object


int stb = 200;                // Time to stabilize tuning           
int minWait = 50;            // Shorter waiting time at a station (ms)
int maxWait = 1000;           // Longer waiting time at a station (ms)
int wait = minWait;           // Downtime at a station
int dw = 50;                 // Rate of change for waiting time at a station (ms)
bool muted = true;            // mute/unmute
short sLevel;                 // Current Signal Level
short minLevel = 3;           // Minimum acceptable signal level
float minFreq = 67.1;         // Lower tunable frequency
float maxFreq = 208.9;        // Higher tunable frequency
float frequency = minFreq;    // Currently tuned frequency
String s;                     // Station frequency in string form
bool stopped = true;          // starts / stops scanning
bool forward = true;          // Sweeps stations forward
bool backward = false;        // Sweeps stations back
float stations[50];           // Station Frequencies Vector (up to 50 stations)
int n_stations;               // Number of stations tuned in
int count = 0;                // Counter Variable


// This function introduces the creator of the program
void splashScreen()
{
  lcd.clear();                        
  lcd.setCursor(0,0);
  lcd.print("Rob Build");
  lcd.setCursor(0,1);
  lcd.print("made by RK (2024)");
  delay(3000);
}


// This function initially scans the available radio stations
void scanStations()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scanning");
  lcd.setCursor(0,1);
  lcd.print("Stations...");
  radio.setMuted(true);               // Mute the radio
  count = 0;                          // Resets the station counter
  lcd.setCursor(15,1);                // Positions the station counter on the screen
  lcd.print(count);                   // Shows the clock of tuned stations
  frequency = minFreq;                // Starts the scan at the lowest frequency
  while (frequency <= maxFreq)        // While not scanning up to the highest frequency
  {
    radio.setFrequency(frequency);    // Setting the radio to the first frequency
    delay(stb);                       // Waits for tuning stabilization
    sLevel = radio.getSignalLevel();  // Captures signal strength at current frequency
    if (sLevel >= minLevel)           // If the signal level is acceptable
    {
      stations[count] = frequency;    // Stores the current station frequency
      count += 1;                     // Increase station counter
      if (count < 20)                 // As long as you don't reach 10 stations
      {
        lcd.setCursor(15,1);          // Positions the cursor at the last position of the second line
      }
      else                            // Otherwise
      {
        lcd.setCursor(14,1);          // Positions the cursor in the second-to-last position of the second line
      }
      lcd.print(count);               // Shows the counter on the screen
    }
    frequency += 0.4;                 // Moves to the next frequency to be probed
  }
  n_stations = count;                 // Write down the number of stations found in the "n_stations" variable
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scaning");
  lcd.setCursor(0,1);
  lcd.print("Completed!");
  delay(2000);
  lcd.clear();
  count = 0;                            // Resets the station counter
  radio.setFrequency(stations[count]);  // Points to the first station tuned in
  displayData();                        // Shows GhostBox data
}


// 
void displayData()
{
  s = String(stations[count]);     // Get station frequency
  lcd.setCursor(0,0);              // Adjusts the position of the display to show the frequency
  if (stations[count] < 50)       // If the station frequency is less than 50 MHz
  {
    lcd.print(" ");                // Adjusts the position to
    lcd.setCursor(1,0);            // Show station frequency
  }
  lcd.print(s);                    // Shows the frequency of the season
  lcd.setCursor(6,0);
  lcd.print("MHz");
  lcd.setCursor(12,0);             // Adjusts the display position to muted/unmuted
  if (muted == true)               // If you're in "mute" mode
  {
    lcd.print("Mute");   // Exhibition "Mute"
  }
  else                   // If you're not in mute mode
  {
    lcd.print("    ");   // Shows "    "
  }
  lcd.setCursor(0,1);
  if (wait < 1000)       // Adjusts the position of the display for standby time < 1000ms
  {
    lcd.print(" ");
    lcd.setCursor(1,1);
  }
  lcd.print(wait);       // Shows the waiting time
  lcd.setCursor(4,1);    // Adjusts the position of the display to show the unit of time (ms)
  lcd.print("ms");       // Shows "ms"
  lcd.setCursor(7,1);    // Adjusts the display position to "Stop" / "Scan"
  if (stopped == true)
  {
    lcd.print("Stop");
  }
  else
  {
    lcd.print("Scan");
  }
  lcd.setCursor(13,1);  // Adjusts the display position to the scan direction "-->" / "<--"
  if (forward == true)
  {
    lcd.print("-->");
  }
  else
  {
    lcd.print("<--");
  }
}


// Scans the next station forward
void goNextRadio()
{
  if (count < n_stations-2)
  {
    count += 1;
  }
  else
  {
    count = 0;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


// Scans the next station backwards
void goPreviousRadio()
{
  if (count > 0)
  {
    count -= 1;
  }
  else
  {
    count = n_stations - 1;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


void setup() {
  delay(1000);
  Wire.begin();
  lcd.begin(16,2);
  splashScreen();    // Shows the Splash screen
  scanStations();    //  Search for available stations
}


int x;
void loop() {
  x = analogRead(0);
  if (stopped == true)
  {
    //---------------------------------------//
    if (x < 60) {
      // "Right" button
      // Sweeps the stations forward
      backward = false;
      forward = true;
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 60 and x < 200) {
      // "Up" button
      // Increases waiting time at a station
      if ((wait + dw) <= maxWait)
      {
        wait += dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 200 and x < 400){
      // "Down" button
      // Decreases waiting time at a station
      if ((wait - dw) >= minWait)
      {
        wait -= dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 400 and x < 600){
      // "Left" button
      // Sweeps the stations back
      forward = false;
      backward = true;
      delay(stb);
    }
  }

  else
  {
    if (forward == true)
    {
      goNextRadio();      // Search for a Forward Station
    }
    if (backward == true)
    {
      goPreviousRadio();   // Search for a back station
    }
    displayData();   // Shows device information
    delay(wait);     // Wait a while at the tuned station
  }

  //---------------------------------------//
  if (x >= 600 and x < 800){
    // "Select" Button
    // This button starts/stops a scan
    if (stopped == false) // If you're doing a scan
    {
      muted = true;    // Mute
      stopped = true;  // Stops the scan
    }
    els

now i want to add this into this code

// TEA5767 Example 
#include <Wire.h> 
#include <TEA5767Radio.h> 

TEA5767Radio radio = TEA5767Radio();

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

void loop ()    {
radio.setFrequency(102.5);   delay (120);
radio.setFrequency(88.1);     delay (120);
radio.setFrequency(88.3);     delay (120);
radio.setFrequency(88.5);     delay (120);
radio.setFrequency(88.7);   delay (120);
radio.setFrequency(88.9);     delay (120);
radio.setFrequency(89.1);     delay (120);
radio.setFrequency(89.1);     delay (120);
radio.setFrequency(89.3);   delay (120);
radio.setFrequency(89.5);     delay (120);
radio.setFrequency(89.7);   delay (120);
radio.setFrequency(89.9);     delay (120);
radio.setFrequency(90.1);     delay (120);
radio.setFrequency(90.3);     delay (120);
radio.setFrequency(90.5);   delay (120);
radio.setFrequency(90.7);     delay (120);
radio.setFrequency(90.9);   delay (120);
radio.setFrequency(91.1);     delay (120);   
radio.setFrequency(91.3);     delay (120);   
radio.setFrequency(91.5);     delay (120);   
radio.setFrequency(91.7);   delay (120);   
radio.setFrequency(91.9);     delay (120);   
radio.setFrequency(92.1);     delay (120);   
radio.setFrequency(92.3);     delay (120);   
radio.setFrequency(92.5);     delay (120);   
radio.setFrequency(92.7);   delay (120);   
radio.setFrequency(92.9);     delay (120);   
radio.setFrequency(93.1);     delay (120);   
radio.setFrequency(93.3);     delay (120);   
radio.setFrequency(93.5);     delay (120);   
radio.setFrequency(93.7);   delay (120);   
radio.setFrequency(93.9);     delay (120);   
radio.setFrequency(94.1);     delay (120);   
radio.setFrequency(94.3);     delay (120);   
radio.setFrequency(94.5);     delay (120);   
radio.setFrequency(94.7);   delay (120);   
radio.setFrequency(94.9);     delay (120);   
radio.setFrequency(95.1);     delay (120);   
radio.setFrequency(95.3);     delay (120);   
radio.setFrequency(95.5);     delay (120);   
radio.setFrequency(95.7);   delay (120);   
radio.setFrequency(95.9);     delay (120);   
radio.setFrequency(96.1);     delay (120);   
radio.setFrequency(96.3);     delay (120);   
radio.setFrequency(96.5);     delay (120);   
radio.setFrequency(96.7);   delay (120);   
radio.setFrequency(96.9);     delay (120);   
radio.setFrequency(96.9);   delay (120);   
radio.setFrequency(97.1);     delay (120);   
radio.setFrequency(97.3);     delay (120);   
radio.setFrequency(97.5);     delay (120);   
radio.setFrequency(97.7);   delay (120);   
radio.setFrequency(97.9);     delay (120);   
radio.setFrequency(98.1);     delay (120);   
radio.setFrequency(98.3);     delay (120);   
radio.setFrequency(98.5);     delay (120);   
radio.setFrequency(98.7);   delay (120);   
radio.setFrequency(98.9);     delay (120);   
radio.setFrequency(99.1);     delay (120);   
radio.setFrequency(99.3);     delay (120);   
radio.setFrequency(99.5);     delay (120);   
radio.setFrequency(99.7);   delay (120);   
radio.setFrequency(99.9);     delay (120);   
radio.setFrequency(100.1);     delay (120);   
radio.setFrequency(100.3);     delay (120);   
radio.setFrequency(100.5);     delay (120);   
radio.setFrequency(100.7);   delay (120);   
radio.setFrequency(100.9);     delay (120);   
radio.setFrequency(100.3);   delay (120);   
radio.setFrequency(100.9);   delay (120);   
radio.setFrequency(101.1);     delay (120);   
radio.setFrequency(101.3);     delay (120);   
radio.setFrequency(101.5);     delay (120);   
radio.setFrequency(101.7);   delay (120);   
radio.setFrequency(101.9);     delay (120);   
radio.setFrequency(102.1);     delay (120);   
radio.setFrequency(102.3);     delay (120);   
radio.setFrequency(102.5);     delay (120);   
radio.setFrequency(102.7);   delay (120);   
radio.setFrequency(102.9);     delay (120);   
radio.setFrequency(103.1);     delay (120);   
radio.setFrequency(103.3);     delay (120);   
radio.setFrequency(103.5);     delay (120);   
radio.setFrequency(103.7);   delay (120);   
radio.setFrequency(103.9);     delay (120);   
radio.setFrequency(104.1);     delay (120);   
radio.setFrequency(104.3);     delay (120);   
radio.setFrequency(104.5);     delay (120);   
radio.setFrequency(104.7);   delay (120);   
radio.setFrequency(104.9);     delay (120);   
radio.setFrequency(105.1);     delay (120);   
radio.setFrequency(105.3);     delay (120);   
radio.setFrequency(105.5);     delay (120);   
radio.setFrequency(105.7);   delay (120);   
radio.setFrequency(105.9);     delay (120);   
radio.setFrequency(106.1);     delay (120);   
radio.setFrequency(106.3);     delay (120);   
radio.setFrequency(106.5);     delay (120);   
radio.setFrequency(106.7);   delay (120);   
radio.setFrequency(106.9);     delay (120);   
radio.setFrequency(107.1);     delay (120);   
radio.setFrequency(107.3);     delay (120);   
radio.setFrequency(107.5);     delay (120);   
radio.setFrequency(107.7);   delay (120);   
radio.setFrequency(107.9);     delay (120);   
radio.setFrequency(108.1);   delay (20);    
}

Or anything to get more white noise or static

Welcome,

Please edit your post, select all code and apply code tags (using the <CODE/> button); next save your post.
This makes it easier to read, easier to copy and prevents the forum software from interpreting the code as formatting instructions.

1 Like

I'd like to add more frequencies like default or once. You're just static like like from this code I'd like to add

// TEA5767 Example 
#include <Wire.h> 
#include <TEA5767Radio.h> 

TEA5767Radio radio = TEA5767Radio();

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

void loop ()    {
radio.setFrequency(102.5);   delay (120);
radio.setFrequency(88.1);     delay (120);
radio.setFrequency(88.3);     delay (120);
radio.setFrequency(88.5);     delay (120);
radio.setFrequency(88.7);   delay (120);
radio.setFrequency(88.9);     delay (120);
radio.setFrequency(89.1);     delay (120);
radio.setFrequency(89.1);     delay (120);
radio.setFrequency(89.3);   delay (120);
radio.setFrequency(89.5);     delay (120);
radio.setFrequency(89.7);   delay (120);
radio.setFrequency(89.9);     delay (120);
radio.setFrequency(90.1);     delay (120);
radio.setFrequency(90.3);     delay (120);
radio.setFrequency(90.5);   delay (120);
radio.setFrequency(90.7);     delay (120);
radio.setFrequency(90.9);   delay (120);
radio.setFrequency(91.1);     delay (120);   
radio.setFrequency(91.3);     delay (120);   
radio.setFrequency(91.5);     delay (120);   
radio.setFrequency(91.7);   delay (120);   
radio.setFrequency(91.9);     delay (120);   
radio.setFrequency(92.1);     delay (120);   
radio.setFrequency(92.3);     delay (120);   
radio.setFrequency(92.5);     delay (120);   
radio.setFrequency(92.7);   delay (120);   
radio.setFrequency(92.9);     delay (120);   
radio.setFrequency(93.1);     delay (120);   
radio.setFrequency(93.3);     delay (120);   
radio.setFrequency(93.5);     delay (120);   
radio.setFrequency(93.7);   delay (120);   
radio.setFrequency(93.9);     delay (120);   
radio.setFrequency(94.1);     delay (120);   
radio.setFrequency(94.3);     delay (120);   
radio.setFrequency(94.5);     delay (120);   
radio.setFrequency(94.7);   delay (120);   
radio.setFrequency(94.9);     delay (120);   
radio.setFrequency(95.1);     delay (120);   
radio.setFrequency(95.3);     delay (120);   
radio.setFrequency(95.5);     delay (120);   
radio.setFrequency(95.7);   delay (120);   
radio.setFrequency(95.9);     delay (120);   
radio.setFrequency(96.1);     delay (120);   
radio.setFrequency(96.3);     delay (120);   
radio.setFrequency(96.5);     delay (120);   
radio.setFrequency(96.7);   delay (120);   
radio.setFrequency(96.9);     delay (120);   
radio.setFrequency(96.9);   delay (120);   
radio.setFrequency(97.1);     delay (120);   
radio.setFrequency(97.3);     delay (120);   
radio.setFrequency(97.5);     delay (120);   
radio.setFrequency(97.7);   delay (120);   
radio.setFrequency(97.9);     delay (120);   
radio.setFrequency(98.1);     delay (120);   
radio.setFrequency(98.3);     delay (120);   
radio.setFrequency(98.5);     delay (120);   
radio.setFrequency(98.7);   delay (120);   
radio.setFrequency(98.9);     delay (120);   
radio.setFrequency(99.1);     delay (120);   
radio.setFrequency(99.3);     delay (120);   
radio.setFrequency(99.5);     delay (120);   
radio.setFrequency(99.7);   delay (120);   
radio.setFrequency(99.9);     delay (120);   
radio.setFrequency(100.1);     delay (120);   
radio.setFrequency(100.3);     delay (120);   
radio.setFrequency(100.5);     delay (120);   
radio.setFrequency(100.7);   delay (120);   
radio.setFrequency(100.9);     delay (120);   
radio.setFrequency(100.3);   delay (120);   
radio.setFrequency(100.9);   delay (120);   
radio.setFrequency(101.1);     delay (120);   
radio.setFrequency(101.3);     delay (120);   
radio.setFrequency(101.5);     delay (120);   
radio.setFrequency(101.7);   delay (120);   
radio.setFrequency(101.9);     delay (120);   
radio.setFrequency(102.1);     delay (120);   
radio.setFrequency(102.3);     delay (120);   
radio.setFrequency(102.5);     delay (120);   
radio.setFrequency(102.7);   delay (120);   
radio.setFrequency(102.9);     delay (120);   
radio.setFrequency(103.1);     delay (120);   
radio.setFrequency(103.3);     delay (120);   
radio.setFrequency(103.5);     delay (120);   
radio.setFrequency(103.7);   delay (120);   
radio.setFrequency(103.9);     delay (120);   
radio.setFrequency(104.1);     delay (120);   
radio.setFrequency(104.3);     delay (120);   
radio.setFrequency(104.5);     delay (120);   
radio.setFrequency(104.7);   delay (120);   
radio.setFrequency(104.9);     delay (120);   
radio.setFrequency(105.1);     delay (120);   
radio.setFrequency(105.3);     delay (120);   
radio.setFrequency(105.5);     delay (120);   
radio.setFrequency(105.7);   delay (120);   
radio.setFrequency(105.9);     delay (120);   
radio.setFrequency(106.1);     delay (120);   
radio.setFrequency(106.3);     delay (120);   
radio.setFrequency(106.5);     delay (120);   
radio.setFrequency(106.7);   delay (120);   
radio.setFrequency(106.9);     delay (120);   
radio.setFrequency(107.1);     delay (120);   
radio.setFrequency(107.3);     delay (120);   
radio.setFrequency(107.5);     delay (120);   
radio.setFrequency(107.7);   delay (120);   
radio.setFrequency(107.9);     delay (120);   
radio.setFrequency(108.1);   delay (20);    
}

Your sketches are missing a lot... your code block ends in ...

    els

and all the frequencies are missing...

    void loop () {
      radio.setFrequency(102.5); delay (120);
      radio.setFrequency(88.1); delay (120);
      radio.setFrequency(88.3); delay (120);
      radio.setFrequency(88.5); delay (120);
      radio.setFrequency(88.7); delay (120);
      radio.setFrequency(88.9); delay (120);
      radio.setFrequency(89.1); delay (120);
      radio.setFrequency(89.1); delay (120);
      radio.setFrequency(89.3); delay (120);
      radio.setFrequency(89.5); delay (120);
      radio.setFrequency(89.7); delay (120);
      radio.setFrequency(89.9); delay (120);
      radio.setFrequency(90.1); delay (120);
      radio.setFrequency(90.3); delay (120);
      radio.setFrequency(90.5); delay (120);
      radio.setFrequency(90.7); delay (120);
      radio.setFrequency(90.9); delay (120);
      radio.setFrequency(91.1); delay (120);
      radio.setFrequency(91.3); delay (120);
      radio.setFrequency(91.5); delay (120);
      radio.setFrequency(91.7); delay (120);
      radio.setFrequency(91.9); delay (120);
      radio.setFrequency(92.1); delay (120);
      radio.setFrequency(92.3); delay (120);
      radio.setFrequency(92.5); delay (120);
      radio.setFrequency(92.7); delay (120);
      radio.setFrequency(92.9); delay (120);
      radio.setFrequency(93.1); delay (120);
      radio.setFrequency(93.3); delay (120);
      radio.setFrequency(93.5); delay (120);
      radio.setFrequency(93.7); delay (120);
      radio.setFrequency(93.9); delay (120);
      radio.setFrequency(94.1); delay (120);
      radio.setFrequency(94.3); delay (120);
      radio.setFrequency(94.5); delay (120);
      radio.setFrequency(94.7); delay (120);
      radio.setFrequency(94.9); delay (120);
      radio.setFrequency(95.1); delay (120);
      radio.setFrequency(95.3); delay (120);
      radio.setFrequency(95.5); delay (120);
      radio.setFrequency(95.7); delay (120);
      radio.setFrequency(95.9); delay (120);
      radio.setFrequency(96.1); delay (120);
      radio.setFrequency(96.3); delay (120);
      radio.setFrequency(96.5); delay (120);
      radio.setFrequency(96.7); delay (120);
      radio.setFrequency(96.9); delay (120);
      radio.setFrequency(96.9); delay (120);
      radio.setFrequency(97.1); delay (120);
      radio.setFrequency(97.3); delay (120);
      radio.setFrequency(97.5); delay (120);
      radio.setFrequency(97.7); delay (120);
      radio.setFrequency(97.9); delay (120);
      radio.setFrequency(98.1); delay (120);
      radio.setFrequency(98.3); delay (120);
      radio.setFrequency(98.5); delay (120);
      radio.setFrequency(98.7); delay (120);
      radio.setFrequency(98.9); delay (120);
      radio.setFrequency(99.1); delay (120);
      radio.setFrequency(99.3); delay (120);
      radio.setFrequency(99.5); delay (120);
      radio.setFrequency(99.7); delay (120);
      radio.setFrequency(99.9); delay (120);
      radio.setFrequency(100.1); delay (120);
      radio.setFrequency(100.3); delay (120);
      radio.setFrequency(100.5); delay (120);
      radio.setFrequency(100.7); delay (120);
      radio.setFrequency(100.9); delay (120);
      radio.setFrequency(100.3); delay (120);
      radio.setFrequency(100.9); delay (120);
      radio.setFrequency(101.1); delay (120);
      radio.setFrequency(101.3); delay (120);
      radio.setFrequency(101.5); delay (120);
      radio.setFrequency(101.7); delay (120);
      radio.setFrequency(101.9); delay (120);
      radio.setFrequency(102.1); delay (120);
      radio.setFrequency(102.3); delay (120);
      radio.setFrequency(102.5); delay (120);
      radio.setFrequency(102.7); delay (120);
      radio.setFrequency(102.9); delay (120);
      radio.setFrequency(103.1); delay (120);
      radio.setFrequency(103.3); delay (120);
      radio.setFrequency(103.5); delay (120);
      radio.setFrequency(103.7); delay (120);
      radio.setFrequency(103.9); delay (120);
      radio.setFrequency(104.1); delay (120);
      radio.setFrequency(104.3); delay (120);
      radio.setFrequency(104.5); delay (120);
      radio.setFrequency(104.7); delay (120);
      radio.setFrequency(104.9); delay (120);
      radio.setFrequency(105.1); delay (120);
      radio.setFrequency(105.3); delay (120);
      radio.setFrequency(105.5); delay (120);
      radio.setFrequency(105.7); delay (120);
      radio.setFrequency(105.9); delay (120);
      radio.setFrequency(106.1); delay (120);
      radio.setFrequency(106.3); delay (120);
      radio.setFrequency(106.5); delay (120);
      radio.setFrequency(106.7); delay (120);
      radio.setFrequency(106.9); delay (120);
      radio.setFrequency(107.1); delay (120);
      radio.setFrequency(107.3); delay (120);
      radio.setFrequency(107.5); delay (120);
      radio.setFrequency(107.7); delay (120);
      radio.setFrequency(107.9); delay (120);
      radio.setFrequency(108.1); delay (20);
    }

What if you replaced all those statements with this

float v  = static_cast<float>(random(100)) / 10.0;
radio.setFrequency(88.1 + v);
delay(120);

where in this code would i put that then

#include <Wire.h>
#include <TEA5767.h>
#include <LiquidCrystal.h>


LiquidCrystal lcd( 8,  9,  4,  5,  6,  7);
TEA5767 radio = TEA5767();    // Creates the radio object


int stb = 200;                // Time to stabilize tuning           
int minWait = 50;            // Shorter waiting time at a station (ms)
int maxWait = 1000;           // Longer waiting time at a station (ms)
int wait = minWait;           // Downtime at a station
int dw = 50;                 // Rate of change for waiting time at a station (ms)
bool muted = true;            // mute/unmute
short sLevel;                 // Current Signal Level
short minLevel = 3;           // Minimum acceptable signal level
float minFreq = 67.1;         // Lower tunable frequency
float maxFreq = 208.9;        // Higher tunable frequency
float frequency = minFreq;    // Currently tuned frequency
String s;                     // Station frequency in string form
bool stopped = true;          // starts / stops scanning
bool forward = true;          // Sweeps stations forward
bool backward = false;        // Sweeps stations back
float stations[50];           // Station Frequencies Vector (up to 50 stations)
int n_stations;               // Number of stations tuned in
int count = 0;                // Counter Variable


// This function introduces the creator of the program
void splashScreen()
{
  lcd.clear();                        
  lcd.setCursor(0,0);
  lcd.print("Rob Build");
  lcd.setCursor(0,1);
  lcd.print("made by RK (2024)");
  delay(3000);
}


// This function initially scans the available radio stations
void scanStations()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scanning");
  lcd.setCursor(0,1);
  lcd.print("Stations...");
  radio.setMuted(true);               // Mute the radio
  count = 0;                          // Resets the station counter
  lcd.setCursor(15,1);                // Positions the station counter on the screen
  lcd.print(count);                   // Shows the clock of tuned stations
  frequency = minFreq;                // Starts the scan at the lowest frequency
  while (frequency <= maxFreq)        // While not scanning up to the highest frequency
  {
    radio.setFrequency(frequency);    // Setting the radio to the first frequency
    delay(stb);                       // Waits for tuning stabilization
    sLevel = radio.getSignalLevel();  // Captures signal strength at current frequency
    if (sLevel >= minLevel)           // If the signal level is acceptable
    {
      stations[count] = frequency;    // Stores the current station frequency
      count += 1;                     // Increase station counter
      if (count < 20)                 // As long as you don't reach 10 stations
      {
        lcd.setCursor(15,1);          // Positions the cursor at the last position of the second line
      }
      else                            // Otherwise
      {
        lcd.setCursor(14,1);          // Positions the cursor in the second-to-last position of the second line
      }
      lcd.print(count);               // Shows the counter on the screen
    }
    frequency += 0.4;                 // Moves to the next frequency to be probed
  }
  n_stations = count;                 // Write down the number of stations found in the "n_stations" variable
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scaning");
  lcd.setCursor(0,1);
  lcd.print("Completed!");
  delay(2000);
  lcd.clear();
  count = 0;                            // Resets the station counter
  radio.setFrequency(stations[count]);  // Points to the first station tuned in
  displayData();                        // Shows GhostBox data
}


// 
void displayData()
{
  s = String(stations[count]);     // Get station frequency
  lcd.setCursor(0,0);              // Adjusts the position of the display to show the frequency
  if (stations[count] < 50)       // If the station frequency is less than 50 MHz
  {
    lcd.print(" ");                // Adjusts the position to
    lcd.setCursor(1,0);            // Show station frequency
  }
  lcd.print(s);                    // Shows the frequency of the season
  lcd.setCursor(6,0);
  lcd.print("MHz");
  lcd.setCursor(12,0);             // Adjusts the display position to muted/unmuted
  if (muted == true)               // If you're in "mute" mode
  {
    lcd.print("Mute");   // Exhibition "Mute"
  }
  else                   // If you're not in mute mode
  {
    lcd.print("    ");   // Shows "    "
  }
  lcd.setCursor(0,1);
  if (wait < 1000)       // Adjusts the position of the display for standby time < 1000ms
  {
    lcd.print(" ");
    lcd.setCursor(1,1);
  }
  lcd.print(wait);       // Shows the waiting time
  lcd.setCursor(4,1);    // Adjusts the position of the display to show the unit of time (ms)
  lcd.print("ms");       // Shows "ms"
  lcd.setCursor(7,1);    // Adjusts the display position to "Stop" / "Scan"
  if (stopped == true)
  {
    lcd.print("Stop");
  }
  else
  {
    lcd.print("Scan");
  }
  lcd.setCursor(13,1);  // Adjusts the display position to the scan direction "-->" / "<--"
  if (forward == true)
  {
    lcd.print("-->");
  }
  else
  {
    lcd.print("<--");
  }
}


// Scans the next station forward
void goNextRadio()
{
  if (count < n_stations-2)
  {
    count += 1;
  }
  else
  {
    count = 0;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


// Scans the next station backwards
void goPreviousRadio()
{
  if (count > 0)
  {
    count -= 1;
  }
  else
  {
    count = n_stations - 1;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


void setup() {
  delay(1000);
  Wire.begin();
  lcd.begin(16,2);
  splashScreen();    // Shows the Splash screen
  scanStations();    //  Search for available stations
}


int x;
void loop() {
  x = analogRead(0);
  if (stopped == true)
  {
    //---------------------------------------//
    if (x < 60) {
      // "Right" button
      // Sweeps the stations forward
      backward = false;
      forward = true;
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 60 and x < 200) {
      // "Up" button
      // Increases waiting time at a station
      if ((wait + dw) <= maxWait)
      {
        wait += dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 200 and x < 400){
      // "Down" button
      // Decreases waiting time at a station
      if ((wait - dw) >= minWait)
      {
        wait -= dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 400 and x < 600){
      // "Left" button
      // Sweeps the stations back
      forward = false;
      backward = true;
      delay(stb);
    }
  }

  else
  {
    if (forward == true)
    {
      goNextRadio();      // Search for a Forward Station
    }
    if (backward == true)
    {
      goPreviousRadio();   // Search for a back station
    }
    displayData();   // Shows device information
    delay(wait);     // Wait a while at the tuned station
  }

  //---------------------------------------//
  if (x >= 600 and x < 800){
    // "Select" Button
    // This button starts/stops a scan
    if (stopped == false) // If you're doing a scan
    {
      muted = true;    // Mute
      stopped = true;  // Stops the scan
    }
    els

Where ever you were planning on putting that long list of setFrequency()'s

Cant seem to find the place to put this code

float v  = static_cast<float>(random(100)) / 10.0;
radio.setFrequency(88.1 + v);
delay(120);

into this code or something like that

#include <Wire.h>
#include <TEA5767.h>
#include <LiquidCrystal.h>


LiquidCrystal lcd( 8,  9,  4,  5,  6,  7);
TEA5767 radio = TEA5767();    // Creates the radio object


int stb = 200;                // Time to stabilize tuning           
int minWait = 50;            // Shorter waiting time at a station (ms)
int maxWait = 1000;           // Longer waiting time at a station (ms)
int wait = minWait;           // Downtime at a station
int dw = 50;                 // Rate of change for waiting time at a station (ms)
bool muted = true;            // mute/unmute
short sLevel;                 // Current Signal Level
short minLevel = 3;           // Minimum acceptable signal level
float minFreq = 67.1;         // Lower tunable frequency
float maxFreq = 208.9;        // Higher tunable frequency
float frequency = minFreq;    // Currently tuned frequency
String s;                     // Station frequency in string form
bool stopped = true;          // starts / stops scanning
bool forward = true;          // Sweeps stations forward
bool backward = false;        // Sweeps stations back
float stations[50];           // Station Frequencies Vector (up to 50 stations)
int n_stations;               // Number of stations tuned in
int count = 0;                // Counter Variable


// This function introduces the creator of the program
void splashScreen()
{
  lcd.clear();                        
  lcd.setCursor(0,0);
  lcd.print("Rob Build");
  lcd.setCursor(0,1);
  lcd.print("made by RK (2024)");
  delay(3000);
}


// This function initially scans the available radio stations
void scanStations()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scanning");
  lcd.setCursor(0,1);
  lcd.print("Stations...");
  radio.setMuted(true);               // Mute the radio
  count = 0;                          // Resets the station counter
  lcd.setCursor(15,1);                // Positions the station counter on the screen
  lcd.print(count);                   // Shows the clock of tuned stations
  frequency = minFreq;                // Starts the scan at the lowest frequency
  while (frequency <= maxFreq)        // While not scanning up to the highest frequency
  {
    radio.setFrequency(frequency);    // Setting the radio to the first frequency
    delay(stb);                       // Waits for tuning stabilization
    sLevel = radio.getSignalLevel();  // Captures signal strength at current frequency
    if (sLevel >= minLevel)           // If the signal level is acceptable
    {
      stations[count] = frequency;    // Stores the current station frequency
      count += 1;                     // Increase station counter
      if (count < 20)                 // As long as you don't reach 10 stations
      {
        lcd.setCursor(15,1);          // Positions the cursor at the last position of the second line
      }
      else                            // Otherwise
      {
        lcd.setCursor(14,1);          // Positions the cursor in the second-to-last position of the second line
      }
      lcd.print(count);               // Shows the counter on the screen
    }
    frequency += 0.4;                 // Moves to the next frequency to be probed
  }
  n_stations = count;                 // Write down the number of stations found in the "n_stations" variable
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scaning");
  lcd.setCursor(0,1);
  lcd.print("Completed!");
  delay(2000);
  lcd.clear();
  count = 0;                            // Resets the station counter
  radio.setFrequency(stations[count]);  // Points to the first station tuned in
  displayData();                        // Shows GhostBox data
}


// 
void displayData()
{
  s = String(stations[count]);     // Get station frequency
  lcd.setCursor(0,0);              // Adjusts the position of the display to show the frequency
  if (stations[count] < 50)       // If the station frequency is less than 50 MHz
  {
    lcd.print(" ");                // Adjusts the position to
    lcd.setCursor(1,0);            // Show station frequency
  }
  lcd.print(s);                    // Shows the frequency of the season
  lcd.setCursor(6,0);
  lcd.print("MHz");
  lcd.setCursor(12,0);             // Adjusts the display position to muted/unmuted
  if (muted == true)               // If you're in "mute" mode
  {
    lcd.print("Mute");   // Exhibition "Mute"
  }
  else                   // If you're not in mute mode
  {
    lcd.print("    ");   // Shows "    "
  }
  lcd.setCursor(0,1);
  if (wait < 1000)       // Adjusts the position of the display for standby time < 1000ms
  {
    lcd.print(" ");
    lcd.setCursor(1,1);
  }
  lcd.print(wait);       // Shows the waiting time
  lcd.setCursor(4,1);    // Adjusts the position of the display to show the unit of time (ms)
  lcd.print("ms");       // Shows "ms"
  lcd.setCursor(7,1);    // Adjusts the display position to "Stop" / "Scan"
  if (stopped == true)
  {
    lcd.print("Stop");
  }
  else
  {
    lcd.print("Scan");
  }
  lcd.setCursor(13,1);  // Adjusts the display position to the scan direction "-->" / "<--"
  if (forward == true)
  {
    lcd.print("-->");
  }
  else
  {
    lcd.print("<--");
  }
}


// Scans the next station forward
void goNextRadio()
{
  if (count < n_stations-2)
  {
    count += 1;
  }
  else
  {
    count = 0;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


// Scans the next station backwards
void goPreviousRadio()
{
  if (count > 0)
  {
    count -= 1;
  }
  else
  {
    count = n_stations - 1;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


void setup() {
  delay(1000);
  Wire.begin();
  lcd.begin(16,2);
  splashScreen();    // Shows the Splash screen
  scanStations();    //  Search for available stations
}


int x;
void loop() {
  x = analogRead(0);
  if (stopped == true)
  {
    //---------------------------------------//
    if (x < 60) {
      // "Right" button
      // Sweeps the stations forward
      backward = false;
      forward = true;
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 60 and x < 200) {
      // "Up" button
      // Increases waiting time at a station
      if ((wait + dw) <= maxWait)
      {
        wait += dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 200 and x < 400){
      // "Down" button
      // Decreases waiting time at a station
      if ((wait - dw) >= minWait)
      {
        wait -= dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 400 and x < 600){
      // "Left" button
      // Sweeps the stations back
      forward = false;
      backward = true;
      delay(stb);
    }
  }

  else
  {
    if (forward == true)
    {
      goNextRadio();      // Search for a Forward Station
    }
    if (backward == true)
    {
      goPreviousRadio();   // Search for a back station
    }
    displayData();   // Shows device information
    delay(wait);     // Wait a while at the tuned station
  }

  //---------------------------------------//
  if (x >= 600 and x < 800){
    // "Select" Button
    // This button starts/stops a scan
    if (stopped == false) // If you're doing a scan
    {
      muted = true;    // Mute
      stopped = true;  // Stops the scan
    }
    els

ok i added it in and now i have this error what am i doing wrong?( added it in line 18)

here the error messages im getting
C:\Users\User\Documents\Arduino\Spirit_Box_TEA5767_Spirit_Box_TEA5767_copy_20240126004630\Spirit_Box_TEA5767_Spirit_Box_TEA5767_copy_20240126004630.ino:18:51: error: 'radio' does not name a type
float v = static_cast(random(100)) / 10.0; radio.setFrequency(88.1 + v); delay(120);
^~~~~
C:\Users\User\Documents\Arduino\Spirit_Box_TEA5767_Spirit_Box_TEA5767_copy_20240126004630\Spirit_Box_TEA5767_Spirit_Box_TEA5767_copy_20240126004630.ino:18:86: error: expected constructor, destructor, or type conversion before '(' token
float v = static_cast(random(100)) / 10.0; radio.setFrequency(88.1 + v); delay(120);
^

exit status 1

Compilation error: 'radio' does not name a type

#include <Wire.h>
#include <TEA5767.h>
#include <LiquidCrystal.h>


LiquidCrystal lcd( 8,  9,  4,  5,  6,  7);
TEA5767 radio = TEA5767();    // Creates the radio object


int stb = 200;                // Time to stabilize tuning           
int minWait = 50;            // Shorter waiting time at a station (ms)
int maxWait = 1000;           // Longer waiting time at a station (ms)
int wait = minWait;           // Downtime at a station
int dw = 50;                 // Rate of change for waiting time at a station (ms)
bool muted = true;            // mute/unmute
short sLevel;                 // Current Signal Level
short minLevel = 3;           // Minimum acceptable signal level
float v  = static_cast ; <float>(random(100)) / 10.0; radio.setFrequency(88.1 + v); delay(120);
float minFreq = 67.1;         // Lower tunable frequency
float maxFreq = 208.9;        // Higher tunable frequency
float frequency = minFreq;    // Currently tuned frequency
String s;                     // Station frequency in string form
bool stopped = true;          // starts / stops scanning
bool forward = true;          // Sweeps stations forward
bool backward = false;        // Sweeps stations back
float stations[50];           // Station Frequencies Vector (up to 50 stations)
int n_stations;               // Number of stations tuned in
int count = 0;                // Counter Variable


// This function introduces the creator of the program
void splashScreen()
{
  lcd.clear();                        
  lcd.setCursor(0,0);
  lcd.print("Rob Build");
  lcd.setCursor(0,1);
  lcd.print("made by RK (2024)");
  delay(3000);
}


// This function initially scans the available radio stations
void scanStations()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scanning");
  lcd.setCursor(0,1);
  lcd.print("Stations...");
  radio.setMuted(true);               // Mute the radio
  count = 0;                          // Resets the station counter
  lcd.setCursor(15,1);                // Positions the station counter on the screen
  lcd.print(count);                   // Shows the clock of tuned stations
  frequency = minFreq;                // Starts the scan at the lowest frequency
  while (frequency <= maxFreq)        // While not scanning up to the highest frequency
  {
    radio.setFrequency(frequency);    // Setting the radio to the first frequency
    delay(stb);                       // Waits for tuning stabilization
    sLevel = radio.getSignalLevel();  // Captures signal strength at current frequency
    if (sLevel >= minLevel)           // If the signal level is acceptable
    {
      stations[count] = frequency;    // Stores the current station frequency
      count += 1;                     // Increase station counter
      if (count < 20)                 // As long as you don't reach 10 stations
      {
        lcd.setCursor(15,1);          // Positions the cursor at the last position of the second line
      }
      else                            // Otherwise
      {
        lcd.setCursor(14,1);          // Positions the cursor in the second-to-last position of the second line
      }
      lcd.print(count);               // Shows the counter on the screen
    }
    frequency += 0.4;                 // Moves to the next frequency to be probed
  }
  n_stations = count;                 // Write down the number of stations found in the "n_stations" variable
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Scaning");
  lcd.setCursor(0,1);
  lcd.print("Completed!");
  delay(2000);
  lcd.clear();
  count = 0;                            // Resets the station counter
  radio.setFrequency(stations[count]);  // Points to the first station tuned in
  displayData();                        // Shows GhostBox data
}


// 
void displayData()
{
  s = String(stations[count]);     // Get station frequency
  lcd.setCursor(0,0);              // Adjusts the position of the display to show the frequency
  if (stations[count] < 50)       // If the station frequency is less than 50 MHz
  {
    lcd.print(" ");                // Adjusts the position to
    lcd.setCursor(1,0);            // Show station frequency
  }
  lcd.print(s);                    // Shows the frequency of the season
  lcd.setCursor(6,0);
  lcd.print("MHz");
  lcd.setCursor(12,0);             // Adjusts the display position to muted/unmuted
  if (muted == true)               // If you're in "mute" mode
  {
    lcd.print("Mute");   // Exhibition "Mute"
  }
  else                   // If you're not in mute mode
  {
    lcd.print("    ");   // Shows "    "
  }
  lcd.setCursor(0,1);
  if (wait < 1000)       // Adjusts the position of the display for standby time < 1000ms
  {
    lcd.print(" ");
    lcd.setCursor(1,1);
  }
  lcd.print(wait);       // Shows the waiting time
  lcd.setCursor(4,1);    // Adjusts the position of the display to show the unit of time (ms)
  lcd.print("ms");       // Shows "ms"
  lcd.setCursor(7,1);    // Adjusts the display position to "Stop" / "Scan"
  if (stopped == true)
  {
    lcd.print("Stop");
  }
  else
  {
    lcd.print("Scan");
  }
  lcd.setCursor(13,1);  // Adjusts the display position to the scan direction "-->" / "<--"
  if (forward == true)
  {
    lcd.print("-->");
  }
  else
  {
    lcd.print("<--");
  }
}


// Scans the next station forward
void goNextRadio()
{
  if (count < n_stations-2)
  {
    count += 1;
  }
  else
  {
    count = 0;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


// Scans the next station backwards
void goPreviousRadio()
{
  if (count > 0)
  {
    count -= 1;
  }
  else
  {
    count = n_stations - 1;
  }
  radio.setFrequency(stations[count]);   // Tune in to the station
  delay(stb);                            // Wait to stabilize the tuning
}


void setup() {
  delay(1000);
  Wire.begin();
  lcd.begin(16,2);
  splashScreen();    // Shows the Splash screen
  scanStations();    //  Search for available stations
}


int x;
void loop() {
  x = analogRead(0);
  if (stopped == true)
  {
    //---------------------------------------//
    if (x < 60) {
      // "Right" button
      // Sweeps the stations forward
      backward = false;
      forward = true;
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 60 and x < 200) {
      // "Up" button
      // Increases waiting time at a station
      if ((wait + dw) <= maxWait)
      {
        wait += dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 200 and x < 400){
      // "Down" button
      // Decreases waiting time at a station
      if ((wait - dw) >= minWait)
      {
        wait -= dw;
      }
      delay(stb);
    }

    //---------------------------------------//
    if (x >= 400 and x < 600){
      // "Left" button
      // Sweeps the stations back
      forward = false;
      backward = true;
      delay(stb);
    }
  }

  else
  {
    if (forward == true)
    {
      goNextRadio();      // Search for a Forward Station
    }
    if (backward == true)
    {
      goPreviousRadio();   // Search for a back station
    }
    displayData();   // Shows device information
    delay(wait);     // Wait a while at the tuned station
  }

  //---------------------------------------//
  if (x >= 600 and x < 800){
    // "Select" Button
    // This button starts/stops a scan
    if (stopped == false) // If you're doing a scan
    {
      muted = true;    // Mute
      stopped = true;  // Stops the scan
    }
    els

Your code does not seem to be complete.

What am i missing

Anything after els

1 Like

Ok i found a easier way to get more Static. All i had to do is play around with this lines to get it to work the way i wanted it

int stb = 200;                // Time to stabilize tuning           
int minWait = 50;            // Shorter waiting time at a station (ms)
int maxWait = 1000;           // Longer waiting time at a station (ms)
int wait = minWait;           // Downtime at a station
int dw = 50;                 // Rate of change for waiting time at a station (ms)
short sLevel;                 // Current Signal Level
short minLevel = 3;           // Minimum acceptable signal level
float minFreq = 67.1;         // Lower tunable frequency
float maxFreq = 208.9;        // Higher tunable frequency
float frequency = minFreq;    // Currently tuned frequency
bool backward = false;        // Sweeps stations back
float stations[50];           // Station Frequencies Vector (up to 50 stations)

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