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
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.
#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
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
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)