The VMA11 (analog) FM RDS radio shield is an old one, but still available. Un fortunately it comes with an example sketch and library that doesn't work properly for European frequency settings. I finally managed to get the library and sketch modified for my purposes. If any one is interested I could forward it off course.
The challenge was to 'abandon' the serial monitor command line and make this whole thing rotary encoder controlled. After a lot of iterations :-), I've got a working setup with two encoders a multiplexer and two LCD20x4 displays. The command line function is still in the sketch, you only have to uncomment it to get it operational.
The use of the multiplexer (in stead of changing the address of one of the LCD displays), caused a lot trouble. The void setup() flow has to be done in a specific order, otherwise there are all kinds of conflicts between the shield and the multiplexer.
So what does it look like.....
* The VMA11 shield sits on the Arduino Uno
* The TCA9548 is hooked up to the sda- and scl-pins
* Two LCD20x4 displays are on bus 0 and 1 of the multiplexer
* Two rotary encoders are connected with digital pins
* Two 3 Watt speaker are connected with the shield
* For convenience I used a mini breadboard
Controls
* Encoder 1 controls the volume.
* Encoder 2 controls a menu with 4 options that is implemented on LCD2:
Display 1
* Row 0 shows station name and frequency
* Row 1,2 and 3 show RDS text
A word of advice: you really need a good quality FM signal for RDS text. At first I thought my code lines were incorrect, but then I found out that if the signal isn't strong enough, you won't receive any data. So when coding, choose a station with a strong signal.
Display 2
* Menu 1. 6 preset stations (programmed in the sketch) you can choose from
* Menu 2. Manual tuning up and down with (European) steps of 100kHz
* Menu 3. Scan function
* Menu 4. Favourite station
I guess the next step will be to make a proper case, but quite frankly I don't care to much about that ;-). Perhaps getting rid of the multiplexer is a better idea. It will certainly make the whole system more stable and faster.
With kind regards (met grote groet)
Michel
/*
This VMA11 shield for the Arduino Uno was released August 2017.
Si4703_Breakout_Modified.cpp library slightly modified for Europe:
- frequency spacing 100 kHz
- elasticity 50kHz
Settings can be done manually in the serial monitor if you uncomment the appropriate function
- frequency scan up/down
- frequency set manually
- preset stations (channels have to programmed in advance in the sketch)
- volume up/down
- frequency scan
So what does it look like.....
* The VMA11 shield sits on the Arduino Uno
* The TCA9548 is hooked up to the sda- and scl-pins
* Two LCD20x4 displays are on bus 0 and 1 of the multiplexer
* Two rotary encoders are connected with digital pins
* Two 3 Watt speaker are connected with the shield
* For convenience I used a mini breadboard
Controls
* Encoder 1 controls the volume.
* Encoder 2 controls a menu with 4 options that is implemented on LCD2:
Display 1
* Row 0 shows station name and frequency
* Row 1,2 and 3 show RDS text
A word of advice: you really need a good quality FM signal for RDS text. At first I thought my code lines were incorrect, but then I found out that if the signal isn't strong enough, you won't receive any data. So when coding, choose a station with a strong signal.
Display 2
* Menu 1. 6 preset stations (programmed in the sketch) you can choose from
* Menu 2. Manual tuning up and down with (European) steps of 100kHz
* Menu 3. Scan function
* Menu 4. Favourite station
The setup requires a specific sequence, to get the radio and multiplexer working.
*/
//Libraries-----------------------------------------------------
#include <VMA11.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//Initialize LCD 1 and 2, once is enough since both are hooked up to a PCA9548 multiplexer
LiquidCrystal_I2C lcd(0x27, 20, 4);
//Rotary encoder 1: volume--------------------------------------
const uint8_t CLK1=7;
const uint8_t DT1=6;
const uint8_t SW1=5;
bool currentStateCLK1;
bool previousStateCLK1;
bool currentStateSW1;
bool previousStateSW1;
//Rotary encoder 2: menu----------------------------------------
const uint8_t CLK2 = 10;
const uint8_t DT2 = 9;
const uint8_t SW2 = 8;
bool currentStateCLK2;
bool previousStateCLK2;
bool currentStateSW2;
bool previousStateSW2;
//Menu----------------------------------------------------------
const char* menuOptions[4]=
{
"Preset stations ",
"Manual tuning ",
"Scan up/down ",
"My favourite BNR"
};
struct RadioPreset
{
int frequency;
const char* name;
};
const RadioPreset presetOptions[6] =
{
{989, "NPORADIO 1"},
{926, "NPORADIO 2"},
{968, "NPORADIO 3"},
{952, "VERONICA"},
{1012, "SKYRADIO"},
{1021, "RADIO538"}
};
uint8_t menuItem=1;
uint8_t previousMenuItem=0;
const uint8_t menuMin=1;
const uint8_t menuMax=4;
uint8_t activeMode=0;
uint8_t previousActiveMode=0;
int tempPreset;//Used in menu option 1
const uint8_t presetMin=0;
const uint8_t presetMax=5;
int tempChannel;//Used in menu option 2
unsigned long lastEncoderMoveTime=0;//Used to force a return to menu item 1 after maxEncoderIdleTime.
const unsigned long maxEncoderIdleTime=5000;
unsigned long lastSW2ReleaseTime;
//Initialize VMA11 shield---------------------------------------
const uint8_t resetPin = 2;
const uint8_t SDIO = A4;
const uint8_t SCLK = A5;
VMA11 radio(resetPin, SDIO, SCLK);
uint8_t volume = 1;
//Channel and frequency-----------------------------------------
int channel;//Used to set the reciever frequency, 95.2MHz is entered as 952.
float displayFreq;//Used to display receiver frequency with decimal digit.
//rds buffers---------------------------------------------------
char rdsName[9]; //Max. 8 characters and terminating 0
char rdsPreviousName[9];
char rdsRadioText[65]; //Max. 64 characters and terminating 0
char rdsPreviousRadioText[65];
uint8_t lastChar;
//Timers--------------------------------------------------------
unsigned long previousCheckrds = 0;
const uint8_t rdsInterval = 20; //Checks rds buffers every 40 ms (trial and error setting that works best)
unsigned long zapTime = 0;
//Other variables-----------------------------------------------
const uint16_t baudrate = 9600;
//Setup---------------------------------------------------------
void setup()
{
Serial.begin(baudrate);
Serial.println(F("--- STARTING SYSTEM ---"));
//1. I2C forced free (software I2C-de-glitch)----------------
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
delay(100);
//2. Hardware reset of the radio shield through pin 2--------
Serial.println(F("Radio hardware reset..."));
pinMode(resetPin, OUTPUT);
digitalWrite(resetPin, LOW);
delay(100);
digitalWrite(resetPin, HIGH); // Haal uit reset
delay(100);
//3. Start I2C library---------------------------------------
//Wire.begin() will assume normal control of the I2C bus
Wire.begin();
delay(100);
//4. Switch off all multiplexer channels---------------------
//Writing 0x00 to the multiplexer (0x70) will disable all channels (0 t/m 7).
//Thus assuring no interference from the LCD displays.
Serial.println(F("Isolating multiplexer bus 0 - 7..."));
Wire.beginTransmission(0x70);
Wire.write(0x00);
int m_status = Wire.endTransmission();
if(m_status == 0) Serial.println(F("Multiplexer responds adequately!"));
else Serial.println(F("Multiplexer CRASH or not found!"));
delay(100);
//5. Start the VMA11 radio shield---------------------------
Serial.println(F("Radio initialized through VMA11 library..."));
radio.powerOn();
radio.setVolume(volume);
channel = 989; //Starting with NPO Radio 2
radio.setChannel(channel);
Serial.println(F("Radio ONLINE en stable!"));
delay(100);
// 6. Initialize LCD's 1 and 2--------------------------------
Serial.println(F("Starting LCD initializing sequence..."));
// --- LCD 1 (bus 0) ---
Serial.println(F("Activate multiplexer on bus 0..."));
TCASELECT(0);
delay(100);
Serial.println(F("Initializing LCD 1..."));
lcd.init();
lcd.backlight();
lcd.clear();
lcd.print(F("Display 1 OK"));
Serial.println(F("LCD 1 ready"));
// --- LCD 2 (bus 1) ---
Serial.println(F("Activate multiplexer on bus 1..."));
TCASELECT(1);
delay(100);
Serial.println(F("Initializing LCD 2..."));
lcd.init();
lcd.backlight();
lcd.clear();
lcd.print(F("Display 2 OK"));
Serial.println(F("LCD 2 ready!"));
//7. Configurating encoder 1 and 2----------------------------
Serial.println(F("Configuration of encoder 1..."));
pinMode(CLK1, INPUT);
pinMode(DT1, INPUT);
pinMode(SW1, INPUT_PULLUP);
previousStateCLK1 = digitalRead(CLK1);
previousStateSW1 = HIGH;
Serial.println(F("Configuration of encoder 2..."));
pinMode(CLK2, INPUT);
pinMode(DT2, INPUT);
pinMode(SW2, INPUT_PULLUP);
previousStateCLK2 = digitalRead(CLK2);
previousStateSW2 = HIGH;
//8. Clead RDS buffers----------------------------------------
Serial.println(F("Clean RDS buffers"));
memset(rdsName, 0, 9);
memset(rdsPreviousName, 0, 9);
memset(rdsRadioText, 0, 65);
memset(rdsPreviousRadioText, 0, 65);
lastChar = 0;
//9. Write initial radio frequency on LCD 1---------------
TCASELECT(0);
channel = radio.getChannel();
displayFreq = channel / 10.0;
lcd.clear();
lcd.setCursor(11, 0);
lcd.print(displayFreq,1);
lcd.setCursor(17,0);
lcd.print(F("MHz"));
//10. Update menu on LCD 2 for the first time-----------------
TCASELECT(1);
lcd.clear();
updateMenuOnLCD2();
//11. Setup completed-----------------------------------------
Serial.println(F("--- SETUP VOLTOOID ---"));
//12. Display freeram (check your optimization efforts--------
display_freeram();
}
//End of setup--------------------------------------------------
//Loop----------------------------------------------------------
void loop()
{
//Loop 1: Encoder 1 adjust volume-------------------------------
encoder1Volume();
//Loop 2: Encoder 2 menu activate / deactivate------------------
encoderMenuItemActive();
//Loop 3: Encoder 2 menu choose option--------------------------
encoderMenuItem();
//Loop 4: Check RDS buffers every [rdsInterval] milliseconds----
rdsReadAllBuffers();
//Loop 5: Use serial monitor for all your commands
//Un-comment this function and the function declaration at the end of this sketch
//manualCommandsSerialMonitor();
}
//Functions-----------------------------------------------------
//PCA9548 bus selector------------------------------------------
void TCASELECT(uint8_t bus)
{
Wire.beginTransmission(0x70);
Wire.write(1<<bus);
Wire.endTransmission();
}
//--------------------------------------------------------------
// Use rotary encoder 1 for volume control----------------------
void encoder1Volume()
{
currentStateCLK1=digitalRead(CLK1);
if (currentStateCLK1!=previousStateCLK1)//Something happened...
{
if((digitalRead(DT1)==previousStateCLK1))//Increase volume
{
if (volume < 15) volume++;
}
else//Decrease volume
{
if (volume > 0) volume--;
}
radio.setVolume(volume);
Serial.print(F("Volume = ")); Serial.println(volume);
}
previousStateCLK1=currentStateCLK1;
}
//--------------------------------------------------------------
//Update LCD row 0 for each new frequency setting---------------
void updateFrequencyOnLCD1()
{
TCASELECT(0);
lcd.clear();
channel = radio.getChannel();
displayFreq = channel / 10.0;
lcd.setCursor(11,0);
if (channel < 1000) lcd.print(F(" "));
lcd.print(displayFreq, 1);
lcd.print(F(" MHz"));
}
//--------------------------------------------------------------
//Supporting function to get rid of odd/corrupt characters------
void cleanRDS(char* text, int length)
{
for (int i = 0; i < length; i++)
{
char c = text[i];
if (c != 0 && (c < 32 || c > 126))
{
text[i] = ' '; // Replace odd character by blank spaces
}
}
}
//--------------------------------------------------------------
//Read rds buffers and display any changes
void rdsReadAllBuffers()
{
if (millis() - previousCheckrds >= rdsInterval)
{
previousCheckrds = millis();
//Wacht 3 seconds after switching to an other station-------
if (millis() - zapTime > 3000)
{
radio.readRDS(rdsName, rdsRadioText, &lastChar);
cleanRDS(rdsName, 8);
cleanRDS(rdsRadioText, 64);
//Immediately display station name------------------------
if (strcmp(rdsName, rdsPreviousName) != 0)
{
strncpy(rdsPreviousName, rdsName, sizeof(rdsPreviousName) - 1);
rdsPreviousName[sizeof(rdsPreviousName) - 1] = '\0';
TCASELECT(0);
lcd.setCursor(0, 0);
lcd.print(rdsName);
}
//Check updates for new radiotext
if (rdsRadioText[0] != '\0')
{
if (strcmp(rdsRadioText, rdsPreviousRadioText) != 0)
{
strncpy(rdsPreviousRadioText, rdsRadioText, sizeof(rdsPreviousRadioText) - 1);
rdsPreviousRadioText[sizeof(rdsPreviousRadioText) - 1] = '\0';
Serial.print("Radiotext: "); Serial.println(rdsRadioText);
//Display radiotext in the process of building up-----
TCASELECT(0);
showRDSOnLCDRow123NOScrolling(rdsPreviousRadioText);
}
}
}
}
}
//--------------------------------------------------------------
//Clear rds buffers before reading new data
void rdsClearAllBuffers()
{
zapTime = millis(); // Start 3 seconds blockade
memset(rdsName, 0, sizeof(rdsName));
memset(rdsPreviousName, 0, sizeof(rdsPreviousName));
memset(rdsRadioText, 0, sizeof(rdsRadioText));
memset(rdsPreviousRadioText, 0, sizeof(rdsPreviousRadioText));
lastChar = 0;
}
//--------------------------------------------------------------
void showRDSOnLCDRow123NOScrolling(const char* text) {
char row1Buffer[21];
char row2Buffer[21];
char row3Buffer[21];
int totalLength = strlen(text);
// Fill buffers upfront whith blank spaces to prevent ghosting
memset(row1Buffer, ' ', 20); row1Buffer[20] = '\0';
memset(row2Buffer, ' ', 20); row2Buffer[20] = '\0';
memset(row3Buffer, ' ', 20); row3Buffer[20] = '\0';
//Calculate rds row 1
int cutOff1 = 20;
if (totalLength > 20)
{
for (int i = 20; i > 0; i--)
{
if (text[i] == ' ')
{
cutOff1 = i;
break;
}
}
if (cutOff1 == 0) cutOff1 = 20; // Used if no blank space
}
else
{
cutOff1 = totalLength;
}
strncpy(row1Buffer, text, cutOff1);
//Calculate rds row 2
int remainingStart2 = cutOff1;
while (remainingStart2 < totalLength && text[remainingStart2] == ' ') remainingStart2++; // Skip blanks
int cutOff2 = 20;
if (totalLength - remainingStart2 > 20)
{
for (int i = remainingStart2 + 20; i > remainingStart2; i--)
{
if (text[i] == ' ')
{
cutOff2 = i - remainingStart2;
break;
}
}
if (cutOff2 == 0) cutOff2 = 20;
}
else
{
cutOff2 = totalLength - remainingStart2;
}
if (cutOff2 > 0)
{
strncpy(row2Buffer, &text[remainingStart2], cutOff2);
}
//Calculate rds row 3
int remainingStart3 = remainingStart2 + cutOff2;
while (remainingStart3 < totalLength && text[remainingStart3] == ' ') remainingStart3++; // Skip blanks
if (remainingStart3 < totalLength)
{
int remaininglength3 = totalLength - remainingStart3;
// If this still doesn't fit add '...'
if (remaininglength3 > 20)
{
strncpy(row3Buffer, &text[remainingStart3], 17);
row3Buffer[17] = '.'; row3Buffer[18] = '.'; row3Buffer[19] = '.';
}
else
{
strncpy(row3Buffer, &text[remainingStart3], remaininglength3);
}
}
//Close strings and fill open spaces with blanks
row1Buffer[20] = '\0';
row2Buffer[20] = '\0';
row3Buffer[20] = '\0';
for (int i = 19; i >= 0; i--)
{
if (row1Buffer[i] == '\0') row1Buffer[i] = ' ';
if (row2Buffer[i] == '\0') row2Buffer[i] = ' ';
if (row3Buffer[i] == '\0') row3Buffer[i] = ' ';
}
// Write to LCD row 1, 2 and 3
TCASELECT(0);
lcd.setCursor(0, 1);
lcd.print(row1Buffer);
lcd.setCursor(0, 2);
lcd.print(row2Buffer);
lcd.setCursor(0, 3);
lcd.print(row3Buffer);
}
//--------------------------------------------------------------
//Display menu items on LCD2
//Selector: ">" menu item active: "*"
void updateMenuOnLCD2()
{
TCASELECT(1);
for (uint8_t i = 0; i <4; i++)
{
lcd.setCursor(0,i);
if (menuItem == (i+1)) lcd.print(F(">"));
else lcd.print(F(" "));
lcd.print(i+1);
lcd.print(F("."));
lcd.print(menuOptions[i]);
lcd.setCursor(19,i);
if (activeMode == (i + 1))
{
lcd.print("*");
} else {
lcd.print(" ");
}
}
}
//--------------------------------------------------------------
//This menu defines the actions once a menu item has been activated
//Execution of these actions is controlled in "void encoderMenuItemActive"
void encoderMenuItem()
/*
Once a menu option has been activated, an asterisk (*) will appear behind the selected option.
Actions for each selected menu options are as follows
- menu 1 choose a preset station, these must be programmed in advance
- menu 2 manual tune the reciever up or down in steps of 100kHz
- menu 3 auto cycle through frequencies
- menu 4 directly load your favourite station
*/
{
currentStateCLK2 = digitalRead(CLK2);
if (currentStateCLK2 != previousStateCLK2)
{
if (menuItem == 1 && activeMode == 1) // Choose a preset station
{
if((digitalRead(DT2)==previousStateCLK2))//Scroll up presets
{
if (tempPreset == presetMax) tempPreset = presetMin;
else tempPreset++;
}
else //Scroll down presets
{
if (tempPreset == presetMin) tempPreset = presetMax;
else tempPreset--;
}
presetNameOnLCD2();
}
else if (menuItem == 2 && activeMode == 2) //Manual tuning with steps of 100kHz
{
if((digitalRead(DT2)==previousStateCLK2))//Increase frequency by 100kHz
{
if (tempChannel == 1080) tempChannel = 875;
else tempChannel++;
}
else //Decrease frequency bij 100kHz
{
if (tempChannel == 875) tempChannel = 1080;
else tempChannel--;
}
displayFreq=tempChannel/10.0;
//Serial.print("tempChannel = "); Serial.println(displayFreq,1);
tuneFrequencyOnLCD2();
}
else if (menuItem == 3 && activeMode == 3)
{
}
else if (menuItem == 4 && activeMode == 4)
{
}
// Else - option is not active, scroll to next option
else
{
if (digitalRead(DT2) != currentStateCLK2)
{
if (menuItem == menuMax) menuItem = menuMin;
else menuItem++;
}
else
{
if (menuItem == menuMin) menuItem = menuMax;
else menuItem--;
}
}
if (menuItem != previousMenuItem)
{
updateMenuOnLCD2();
previousMenuItem=menuItem;
}
}
previousStateCLK2=currentStateCLK2;
}
void encoderMenuItemActive()
/*
Toggle SW2 on a selected menu option:
- activates a non activated menu: activeMode 0>>1 actions in accordence with function void encoderMenuItem()
- deactivates an activated menu: activeMode 1>>0 AND excecutes the activated menu option
- in menu 1: a preset station frequency is loaded into the receiver
- in menu 2: a manual selected frequency is loaded into the receiver
- in menu 3: an auto scan up is executed and a frequency is loaded into the receiver
- in menu 4: a favourite station frequency is directly loaded into the receiver
*/
{
currentStateSW2 = digitalRead(SW2);
if (currentStateSW2 == HIGH && previousStateSW2 == LOW)
{
// Debounce prevention
if (millis() - lastSW2ReleaseTime > 50)
{
lastSW2ReleaseTime=millis();
switch (menuItem)
{
case 1:
if (activeMode == 1)
{
rdsClearAllBuffers();
channel = presetOptions[tempPreset].frequency;
radio.setChannel(channel);
updateFrequencyOnLCD1();
activeMode = 0;
}
else
{
activeMode = 1;
tempPreset = 0;
}
break;
case 2:
if (activeMode == 2)
{
rdsClearAllBuffers();
channel=tempChannel;
radio.setChannel(channel);
updateFrequencyOnLCD1();
activeMode = 0;
}
else
{
activeMode = 2;
tempChannel = radio.getChannel();
}
break;
case 3:
if (activeMode ==3)
{
rdsClearAllBuffers();
channel = radio.seekUp();
updateFrequencyOnLCD1();
activeMode = 0;
}
else
{
activeMode = 3;
}
break;
case 4:
if (activeMode == 4)
{
rdsClearAllBuffers();
channel=1001;
radio.setChannel(channel);
updateFrequencyOnLCD1();
activeMode = 0;
}
else
{
activeMode = 4;
}
break;
}
updateMenuOnLCD2();
}
}
previousStateSW2=currentStateSW2;
}
//--------------------------------------------------------------
//Display manually tuned frequency on LCD 2---------------------
void tuneFrequencyOnLCD2()
{
TCASELECT(1);
lcd.setCursor(0,1); lcd.print(F(">2 "));
lcd.setCursor(3,1); lcd.print(F("Tuning: "));
lcd.setCursor(11,1);
if(tempChannel<1000) lcd.print(F(" "));
lcd.print(displayFreq,1); lcd.setCursor(17,1); lcd.print(F("MHz"));
}
//--------------------------------------------------------------
//Write name of preset station on LCD 2
void presetNameOnLCD2()
{
TCASELECT(1);
lcd.setCursor(0,0); lcd.print(F(">1 "));
lcd.setCursor(3,0); lcd.print(F("Preset"));
lcd.setCursor(10,0); lcd.print(presetOptions[tempPreset].name);
}
/*
void manualCommandsSerialMonitor()
{
//Manual commands can be inserted in the command line of the serial monitor:
//- 1 - 6 are preset staions,
//- u / d auto scan upwards / downwards,
//- + / - increase / decrease volume,
//- z set a frequency; 102.7 MHz is entered 1027 (do not use the decimal point).
if (Serial.available())
{
char ch = Serial.read();
// At Station change: empty buffers and start zap timer
if (ch == '1' || ch == '2' || ch == '3' || ch == '4' || ch == '5' || ch == '6' || ch == 'u' || ch == 'd' || ch == 'z')
{
rdsClearAllBuffers();
}
switch (ch)
{
case 'u': // Scan up, at 108.0 Mhz next scan up will be 87.5 MHz
channel = radio.seekUp();
updateFrequencyOnLCD1();
break;
case 'd': // Scan down, at 87.5 MHz next scan down will be 108.0 MHz
channel = radio.seekDown();
updateFrequencyOnLCD1();
break;
case '1': // Preset 1 NPORADIO 1
channel = 989;
radio.setChannel(channel);
updateFrequencyOnLCD1();
break;
case '2': // Preset 2 NPORADIO 2
channel = 926;
radio.setChannel(channel);
updateFrequencyOnLCD1();
break;
case '3': // Preset 3 NPORADIO 3
channel = 968;
radio.setChannel(channel);
updateFrequencyOnLCD1();
break;
case '4': // Preset 4 Veronica
channel = 952;
radio.setChannel(channel);
updateFrequencyOnLCD1();
break;
case '5': // Preset 5 SkyRadio
channel = 1012;
radio.setChannel(channel);
updateFrequencyOnLCD1();
break;
case '6': // Preset 6 Radio538
channel = 1021;
radio.setChannel(channel);
updateFrequencyOnLCD1();
break;
case '+': // Increase volume
if (volume<15)
{
volume=volume+1;
radio.setVolume(volume);
}
Serial.print(F("Volume = ")); Serial.println(volume);
break;
case '-': // Decrease volume
if (volume>0)
{
volume=volume-1;
radio.setVolume(volume);
}
Serial.print(F("Volume = ")); Serial.println(volume);
break;
case 'z': // Insert frequency
while (Serial.available() > 0) { Serial.read(); } // Clear the serial.buffer
Serial.print(F("Insert a frequency, enter without decimal dot: 95.2 MHZ = 952: "));
while (Serial.available() == 0 || !isDigit(Serial.peek()))
{
if (Serial.available() > 0 && !isDigit(Serial.peek()))
{
Serial.read();
}
}
channel = Serial.parseInt();
radio.setChannel(channel);
Serial.println(channel);
updateFrequencyOnLCD1();
break;
deafult: // Input not correct
break;
}
}
}
*/
//--------------------------------------------------------------
//Use this function to check optimization effects in your sketch
void display_freeram()
{
Serial.print(F("SRAM left: "));
Serial.print(freeRam());
Serial.println(" Bytes.");
}
int freeRam()
{
extern int __heap_start,*__brkval;
int v;
return (int)&v - (__brkval == 0
? (int)&__heap_start : (int) __brkval);
}



