DAB+ with Arduino UNO and Large Screen

DAB+ with Arduino UNO and Large Screen © GPL3+

With a bigger screen come more possibilities.

  • 8,717 views
  • 6 comments
  • 36 respects

Components and supplies

DAB+/FM tuner T3B
Tuner is slave version without SLS. Original data is protected property but all necessary data is provided when tuner is bought.
×1
Interface pcb for Arduino
×1
Parts for interface
×1
Pushbutton illuminated
These are buttons recovered from a demo panel. These are like Multicomp MPB19 series.
×1
Rotary Encoder
This one is also a recovered one. It is a Bourns ENA1J-28-L00100, with big metal round knob, it has a great 'feel'.
×1
LCD 4x40 characters with backlight
Also a recoverd lcd. It is an Optrex Corporation lcd with a base pcb created by IVEK (Turnhout Belgium). The baseplate has a powersupply for the backlight of the lcd.
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1

About this project

The difference with this one is the use of a bigger screen, 3 push buttons and the use of a rotary switch. Therefore, a whole new user interface had to be developed.

Why 3 buttons, because with the bigger LCD, you need one more output (for en2), and since I also wanted to control the LEDs in the pushbuttons, another output was needed.

To control a 4x40 LCD, you need a special library. I had tried different version, but there was only one that was usable with the 4x40 LCD. After an update of my libraries, my program did not work anymore. I had to reïnstall the older version. I did not investigate why, but you need a certain version of an LCD library (included in this project).

This is the backplane of the LCD. It is a PCB with a supply on board for the backlight of the LCD (top) and some components for controlling the contrast (bottom).

With the bigger screen, it is easier to display a lot of information. In this version data from the radio station is displayed. These are RDS-like messages. These are not slight shows or other graphical data (possible with DAB+ transmission). For this kind of data, one needs a DAB+ tuner with dataservice option.

Here is the result:

The function of the tree buttons are:

LEFT: This is just for on or off. It controls the RESET pin of the tuner and the leds of the buttons. In this version, I don't control the backlight.

MID: This is the mode button. You can set the software in different mode to control, for example, the volume or station frequencies.

RIGHT: When set in a certain mode, you must activate this mode. So you can turn on the rotary switch but when mode is not active, nothing is happening. Or, in FM, you can search for next station, you must activate the search with this select button.

ROTARY ENCODER: With this encoder, you can change different setting, like volume, equalizer. But you also tune in (like a analog radio) on a FM station or select another DAB+ station.

Code

Code for this project.Arduino
//-----------------------------------------------------------------------------
// DAB+ tuner   V3.4c
//
// Created: 12/10/2017 
//
// Commands for DAB+ tuner print.
//
// Author: Staf Van Gestel
//
// With this software you can use the T3B DAB+ tuner on a UNO
// it is written in a way that everyone could understand the software
//
// hardware : UNO; 4X40 lcd; 3 key's; rotary encoder
//  
//The DAB search should be done each time when you use the
// tuner in a new environment.
// The search takes some time.
//
// RESET function : via digitalout 2 (modified interfacd PCB 
// 
// IMPORTANT NOTICE : the baudrate should be at 57601 (as described in some forums).
//
// 25/04/2018 capacitive keys replace by pushbuttons
// 05/05/2018 wijziging in opbouw van scherm en tonen van status
// 22/05/2018 wijzigen van afhandelen van serile data naar voorbeeld van V2.2.3b
//
// 4/03/2019 Program text is not always correct, I have the impression that the 
//           communication with serial buffer is to slow. 
//           So this is an experimenting with stream command. 
//    SUCCES (Don't forget to set Serial timeout !)
// 14/05/2019 Slavesetnotifications changed and some other issues
//----------------------------------------------------------------------------------- 


#include <stdlib.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#include <RotaryEncoder.h>
#include <MsTimer2.h>

LiquidCrystal lcd(13,255,12,11,10,9,8,7); // rs,rw,en1,en2,D4,D5,D6,D7
RotaryEncoder encoder(A1,A0,1,1,100);


/* Next constants are for knowing the playmode or streammode of the tuner */
const byte DAB = 0;
const byte FM = 1;
const byte BEEPER = 2;
const byte AM = 3;
const byte STREAMSTOP = 0xFF;
byte StreamMode = 0;

/* Next constants are for knowing the play status of the tuner */
const byte PlayStatus = 0;
const byte SearchingStatus = 1;
const byte TuningStatus = 2;
const byte StopStatus = 3;
const byte SortingChangeStatus = 4;
const byte ReconfigurationStatus = 5;
byte TunerStatus = 3;

/* Next constants are for knowing the mode the software is in. */

const char BAND = 3;
const char TUNE = 0;
const char SEARCH = 4;
const char VOLUME = 1;
const char SOUND = 2;
const char MAXMODE = 4; // changes this value to previous const, so at this moment this is SOUND
const char BASSBOOST = 0;
const char JAZZ = 1;
const char LIVE = 2;
const char VOCAL = 3;
const char ACOUSTIC = 4;
const char MAXSOUND = 4; // changes this value to previous const.
const char ON = 1;
const char OFF = 2;
const char MAXKOLOM = 40;
byte Mode = 0;

/* next global variabels are for remembering the status of the program */
byte Power = OFF;
byte SignalStrength = 0;
byte BitErrorRate1 = 0;
byte BitErrorRate2 = 0;
byte StereoMode = 0;
byte Stereo = 0;
byte Volume = 8;
byte Sound = 0;
boolean DABChanged = false;  // needed for asking station data only once
boolean FMFreqChanged = false;
boolean ProgTextChanged = false;
//boolean FMProgramNameSet = false;
boolean ProgramNameChanged = false;
boolean VolumeChanged = false;
boolean TimeOut = false;

char InfoText[40];

char ProgText[80]; // Program text can be up to 258 chars (characters seperated with 0x00)
int ProgTextAantChar;
int ProgTextTeller;
char zero = 0x00;  // because of compiler error when using Arduino DUE

int CurrentDABprog = 0;
int totalDABSearchProg = 0;
long totalDABprog = 0;
long FMfrequency = 87500;

byte antenna[8] = {
  0b00100,
  0b10101,
  0b01110,
  0b00100,
  0b00100,
  0b00100,
  0b00100,
  0b00000
};


//----------------------------------------------
// function for checking the respons of the tuner
// Respons is the same for most commands.
//-----------------------------------------------

byte CheckRespons(unsigned int timeout) {

int TOteller = 0;
int index = 0;
int nbrOfSerData = 0;
int aantKar = 0;
byte respons = 0;
unsigned long resp = 0;
long result = 0;
unsigned char ReturnData[270]; // 

do {
   // Time for tuner to respons
   delay(10);
   TOteller++;
   } while ((Serial.available() == 0) && TOteller <= timeout);

if (TOteller >= timeout) {
   return(-2);
   }
// starting to find begin of message, message starts with FE
while (Serial.available() > 0) {

// with Serial.readBytesUntil command, communication is better for programtext.
// but if first byte is not 0XFE then the next commands does'nt work...

aantKar = Serial.readBytesUntil(0xFD,ReturnData,270);



if (aantKar == 0) 
   return(-1);
else
   {
   switch(ReturnData[1]) {
   case 0x00: {                 //ACK   NACK
      switch (ReturnData[2]) {
      case 0x01:    // ACK
         return(0);
         break;        
      case 0x02:   // NACK
         switch (ReturnData[3]) {  //serial number
         case 0x10:  // Get Programname
            if (ReturnData[6] == 0){
//               lcd.setCursor(0,3);
//               lcd.print("NACK No Text INFO available");
               }
            else {
//               lcd.setCursor(0,3);
//               lcd.print("NACK Text available is same");
               }
            return(1);
            break;
         }
         return(1);
         break;
         }
      return(-1);
      break;
      } 
   case 0x01: {
      switch (ReturnData[2]) {
      case 0x05:  // get play status
         TunerStatus = ReturnData[6];
         return(0);
         break;
      case 0x06:  // get play mode;
         StreamMode = ReturnData[6];
         return(0);              
         break;
      case 0x07:  // get play index
         resp = ReturnData[6];
         result += resp << 24;
         resp = ReturnData[7];
         result += resp << 16;
         resp = ReturnData[8];
         result += resp << 8;
         resp = ReturnData[9];
         result += resp;
         if (StreamMode == FM) {
            FMfrequency = result;
            FMFreqChanged = true;
            }
         else if (StreamMode == DAB) {
            CurrentDABprog  = result;
            DABChanged = true;
            }
         return(0);                 
         break;
      case 0x08:  // get signalstrength
//         lcd.setCursor(5,1);
         SignalStrength = ReturnData[6];
         BitErrorRate1 = ReturnData[7];
         BitErrorRate2 = ReturnData[8];
         if (SignalStrength <= 100) {
//            lcd.setCursor(8,1);
            return(0);
            }
         else
            {
//            lcd.setCursor(10,1);                  
            return(1);              
            }
         break;
      case 0x0A: // get stereo mode
         StereoMode = ReturnData[6];
         return(0);
         break;
      case 0x0B: // get stereo
         Stereo = ReturnData[6];
         return(0);
         break;
      case 0x0D: // get volume
         Volume = ReturnData[6];
         return(0);
         break;
      case 0x0F: // get programname  
         ProgramNameChanged = true;
         for (int tel = 0; tel < 16; tel++) 
            InfoText[tel] = ' ';
         aantKar = ReturnData[5];
         index = 0;
         if (aantKar > MAXKOLOM) aantKar = MAXKOLOM;
         for (int tel=7; tel<= (aantKar+6); tel+=2){  //  0x00 between characters
            InfoText[index] = ReturnData[tel];
            index++;
            }
         return(0);
         break;
      case 0x10: // get programtext
         for (int tel = 0; tel < 80; tel++) 
            ProgText[tel] = ' ';
         aantKar = ReturnData[5];
         index = 0;
         for (int tel=6; tel<= (aantKar+4); tel++){  //  0x00 between characters  and EOT
            if ((ReturnData[tel] != 0x00)){ //&&(ReturnData[tel] < 0x7E)){   // 0x7E biggest ASCII value
               ProgText[index] = ReturnData[tel];
               if (index == 79) tel = (aantKar + 10);  // ending procedure to fil ProgText
               index++;
               }
            ProgTextAantChar = index;
            }
//         return(0);
         break;
      case 0x16: // get total program of DAB in database
         resp = ReturnData[6];
         result += resp << 24;
         resp = ReturnData[7];
         result += resp << 16;
         resp = ReturnData[8];
         result += resp << 8;
         resp = ReturnData[9];
         result += resp;
         totalDABprog = result;
         return(0);
         break;
      case 0x1A: // get service name   
         for (int tel = 0; tel < 16; tel++) 
            InfoText[tel] = ' ';
         aantKar = ReturnData[5];
         index = 0;
         if (aantKar > 16) aantKar = 16;
         for (int tel=7; tel<= (aantKar+7); tel+=2){  //  0x00 between characters
            InfoText[index] = ReturnData[tel];
            index++;
            }
         return(0);
         break; 
      case 0x1B: // get search program
         totalDABSearchProg = ReturnData[6];
         return(0);
         break;              
      } 
      return(-2);
      break;       
   }
   case 0x07: // slave notification
      switch (ReturnData[2]) {
      case 0x01:  // new program text
         ProgTextChanged = true;
         break;
/*
      lcd.setCursor(0,3);
      for (int tel=0; tel<10; tel++){
         lcd.print(ReturnData[tel],HEX);
         lcd.print(" ");
         }        
*/
      break;
      }
     return(0);     
//   break;
   }
return(-3);   
}
}
}

//-------------------------------------------------------------
//  SLAVESetNotification
//  With this command you set the slave to send notifications.
//  Here we only set the Scan Frequency Notification
//  The slave returns then the frequency after scanning
//------------------------------------------------------------
 
 byte SLAVESetNotification(void) {

Serial.write(0xFE);
Serial.write(0x07);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x02); 
Serial.write(zero);
//Serial.write(0x7F);
Serial.write(0x02);
Serial.write(0xFD);

return(CheckRespons(1000));
}
//*********************************************************************************/
// GetSysRdy : Asking if system is ready to receive commands
// returns 0 is system is ready,
// returns 1 is system is not ready,
// returns -1 when there is a problem with communication,
// returns -2 no respons from tuner, timeout.
//*********************************************************************************/

byte GetSysRdy(void) {

Serial.write(0xFE);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);

return(CheckRespons(1000));
}
  
//*********************************************************************************/
// SysRstDatabase : reset database
// returns 0 is databasereset is ready,
// returns 1 is system is not ready,
// returns -1 when there is a problem with communication,
// returns -2 no respons from tuner, timeout.
//*********************************************************************************/

byte SysRstDatabase(void) {

Serial.write(0xFE);
Serial.write(zero);
Serial.write(0x01);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x01);
Serial.write(0x02);
Serial.write(0xFD);

return(CheckRespons(1000));
}

//*********************************************************************************/
// GetPlayIndex : Get Program index of current DAB program of FM RF frequency
// returns -1 when there is a problem with communication,
// returns -2 no respons from tuner, timeout.
//*********************************************************************************/

byte GetPlayIndex(void) {

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x07);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);

return(CheckRespons(1000));
}    

//*********************************************************************************/
// GetSignalStrength : Get current signal strength FM or DAB 
// returns signal strength   DAB 0~18  FM 0~100
// returns -1 when there is a problem with communication,
// returns -2 no respons from tuner, timeout.
//*********************************************************************************/

byte GetSignalStrength(void) {

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x08);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);
return(CheckRespons(1000));
}
    
//*********************************************************************************/
// GetServiceName : Get service name of current DAB program
// returns  ,
// returns ,
// returns -1 when there is a problem with communication,
// returns -2 no respons from tuner, timeout.
//*********************************************************************************/

byte GetServiceName(unsigned long DABprogram) {

unsigned char prog1 = DABprogram & 0xFF;
unsigned char prog2 = DABprogram >> 8 & 0xFF;
unsigned char prog3 = DABprogram >> 16 & 0xFF;
unsigned char prog4 = DABprogram >> 24 & 0xFF;
Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x1A);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x05);
Serial.write(prog4);
Serial.write(prog3);
Serial.write(prog2);
Serial.write(prog1);
Serial.write(zero);
Serial.write(0xFD);
return(CheckRespons(1000));
}  

//*********************************************************************************/
// GetProgramText : get current DAB/FM program text
// returns  ,
// returns ,
// returns -1 when there is a problem with communication,
// returns -2 no respons from tuner, timeout.
//*********************************************************************************/

byte GetProgramText(void) {

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x10);
Serial.write(0x10);  // serial number for identifying NACK
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);
return(CheckRespons(1000));
}

//*********************************************************************************/
// GetFMProgramName : get current FM program name
// returns  ,
// returns ,
// returns -1 when there is a problem with communication,
// returns -2 no respons from tuner, timeout.
//*********************************************************************************/

byte GetFMProgramName(void) {

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x0F);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x05);
Serial.write(0xFF);
Serial.write(0xFF);
Serial.write(0xFF);
Serial.write(0xFF);
Serial.write(0x01);
Serial.write(0xFD);

return(CheckRespons(1000));

} 

//*********************************************************************************/
// SetEqualizer : setting equalizer of DAB+tuner
// 
// Parameter is a number from 0 to 4
// Returns status of action
//    0 : EQ is set,
//    1 : EQ is not set; wait and try again,
//   -1 : unknown error, probably communication error,
//   -2 : no respons from tuner.
//*********************************************************************************/

byte SetEqualizer(char sound){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x1F);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x0C);
Serial.write(0x02);
Serial.write(sound);
Serial.write(0x10);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);

return(CheckRespons(1000));
}

//*********************************************************************************/
// SetVolume : setting volume of DAB+tuner
// Initialy the volume is 0 = Mute.
// Parameter is a number from 0 to 16
// Returns status of action
//    0 : volume is set,
//    1 : volume is not set; wait and try again,
//   -1 : unknown error, probably communication error,
//   -2 : no respons from tuner.
//*********************************************************************************/

byte SetVolume(char Volume){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x0C);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x01);
Serial.write(Volume);
Serial.write(0xFD);
return(CheckRespons(1000));

} 

//*********************************************************************************/
// FMSearch : search FM-band
// parameter is direction of search : 0 = backward or 1 = forward
// Returns status of action 
//    0 : search is done 
//    1 : search is not done; wait and try again
//   -1 : unknown error, probably communication error
//   -2 : no respons from unit.
//*********************************************************************************/

byte FMSearch(char Direction){

byte response = 0;
int teller;

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x02);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x01);
Serial.write(Direction);
Serial.write(0xFD);


response = CheckRespons(1000);
if (response == 0){
   lcd.clear();
   lcd.print("FMSearch starts");
   TunerStatus = SearchingStatus;
   lcd.setCursor(0,1);
   teller = 0;         
   while (TunerStatus == SearchingStatus){   
      response = GetTunerPlayStatus();
      delay(1000);
      teller++;
      if (teller > 15) {
         teller = 0;
         lcd.setCursor(0,1);
         lcd.print("                ");
         lcd.setCursor(0,1);               
         }
      lcd.print('.');
      }
   response = GetPlayIndex();
   }
return (response);
} 


//*********************************************************************************/
// SetFMFreq : setting tuner on certain frequency
// Frequency must be set in hex code
// Parameter is a frequency from  155CC (87500 kHz) to 1A5E0 (108000 kHz).
// Returns status of action 
//    0 : freq is set,
//    1 : freq is not set; wait and try again,
//   -1 : unknown error, probably communication error,
//   -2 : no repsons from tuner.
//*********************************************************************************/

byte SetFMFreq(unsigned long frequency){

unsigned char freq1 = frequency & 0xFF;
unsigned char freq2 = frequency >> 8 & 0xFF;
unsigned char freq3 = frequency >> 16 & 0xFF;
unsigned char freq4 = frequency >> 24 & 0xFF;
Serial.write(0xFE);
Serial.write(0x01);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x05);
Serial.write(0x01);
Serial.write(freq4);
Serial.write(freq3);
Serial.write(freq2);
Serial.write(freq1);
Serial.write(0xFD);

return(CheckRespons(1000));
} 

//*********************************************************************************/
// StopFMFreq : stopping current FM stream
// 
// Returns status of action 
//    0 : streaming is stopped,
//    1 : streaming is not stopped, perhaps streaming was not started,
//   -1 : unknown error, probably communication error,
//   -2 : no respons from tuner.
//*********************************************************************************/

byte StopFMFreq(void){

int index = 0;
unsigned char response[10];

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x01);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);

return(CheckRespons(500));
} 

//*********************************************************************************/
// SetDABProg : setting DAB+tuner on certain program
// Program must be between 0 and (STREAM_GetTotalProgram -1)
// Returns status of action
//    0 : prog is set,
//    1 : prog is not set; wait and try again,
//   -1 : unknown error, probably communication error,
//   -2 : no respons from tuner.
//*********************************************************************************/

byte SetDABProg(char program){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x05);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(program);
Serial.write(0xFD);

return(CheckRespons(1000));
}

//*********************************************************************************/
// SearchDAB : start DAB search process
// The module will search every frequency between start- and endfrequency.
// Not the frequency itself is used, but indexes (1-40) are used.
// Returns status of action
//    0 : search is done,
//    1 : search is not done; wait and try again,
//   -1 : unknown error, probably communication error,
//   -2 : no respons from tuner.
//*********************************************************************************/

byte SearchDAB(char startindex, char stopindex){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x03);
Serial.write(zero);
Serial.write(zero);
Serial.write(0x02);  
Serial.write(startindex);
Serial.write(stopindex);
Serial.write(0xFD);

return(CheckRespons(5000));
}
   
//*********************************************************************************/
// GetVolume : getting volume of DAB+tuner
// 
// Parameter is a number from 0 to 16
// Returns status of action or volume level
//    0--16: volume, 
//   -1 : unknown error, probably communication error,
//   -2 : no respons from tuner.
//*********************************************************************************/

byte GetVolume(void){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x0D);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);
return(CheckRespons(1000));
}
//*********************************************************************************/
// GetDABTotalSearchProg : total programs found in search process
// Returns status of action
//    0 : prog is set,
//   -1 : unknown error, probably communication error,
//*********************************************************************************/
byte GetDABTotalSearchProg(void){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x1B);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);
return(CheckRespons(1000));
}

//*********************************************************************************/
// GetDABTotalProg : Total of stations found in DAB database
// Returns one of the following 
//    # number of programs,
//    1 : prog is not set; wait and try again,
//   -1 : unknown error, probably communication error,
//   -2 : no respons from tuner.
//*********************************************************************************/
byte GetDABTotalProg(void){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x16);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);
return(CheckRespons(1000));
}

//*************************************************************/
// GetTunerPlayStatus : Getting Status of Tuner
// Returns status of command
//    0 : command executed,
//   -1 : unknown error, probably communication error,
//*************************************************************/
byte GetTunerPlayStatus(void){

Serial.write(0xFE);
Serial.write(0x01);
Serial.write(0x05);
Serial.write(zero);
Serial.write(zero);
Serial.write(zero);
Serial.write(0xFD);
return(CheckRespons(10000));
}

//--------------------------------------
// ShowSignalStrength
//--------------------------------------

void ShowSignalStrength(){

int respons=0;

respons = GetSignalStrength();
lcd.setCursor(34,0);
lcd.write(0);
lcd.print(":   ");
lcd.setCursor(36,0);
if (respons == 0) {
   if (SignalStrength < 100)
      {
      lcd.print(SignalStrength);
      }
   else {
      lcd.print("ERR");
      }
   }
}

//---------------------------------------
//  SetDisplay
//  procedure to display info on lcd
//---------------------------------------

void SetDisplay(){

int response;
int aantKar;
int index = 0;
double Frequency = 0.0;

unsigned long resp = 0;

lcd.clear();

lcd.setCursor(0,0);
if (StreamMode == DAB) {
   lcd.print("DAB+");
   lcd.setCursor(7,0);
   lcd.print("#Stations:     ");
   lcd.setCursor(17,0);
   lcd.print(totalDABprog);
   lcd.setCursor(0,1);
   lcd.print("Prog:     ");
   lcd.setCursor(5,1);
   lcd.print(CurrentDABprog+1);
   }
else {
   lcd.print("FM  ");
   }
lcd.setCursor(23,0);
lcd.print("VOL:");
lcd.print("  ");
lcd.setCursor(27,0);
lcd.print(Volume);

if (StreamMode == DAB){ 
   response = GetServiceName(CurrentDABprog);
   lcd.setCursor(10,1);
   lcd.print(InfoText);    
   }
 
if (StreamMode == FM) {
   if (FMFreqChanged == true){
      FMFreqChanged = false;
      response = GetPlayIndex();
      lcd.setCursor(0,1);
      lcd.print((FMfrequency/1000.0));
      lcd.print(" MHz         ");
      delay(1000);
      response = GetFMProgramName();
      if (response == 0) {
         lcd.setCursor(3,0);
         lcd.print(InfoText);    
         }     
      }
   }
if (Mode > MAXMODE) Mode = 0;
   lcd.setCursor(0,2);
   lcd.print("Mode : ");      
   switch (Mode) {
      case BAND:
         if (StreamMode == FM)
            lcd.print("FM                  ");
         else
            lcd.print("DAB+                ");
         delay(1000);
         break;
      case TUNE: 
         lcd.print("Tune station           ");
         delay(1000);
         break;
      case SEARCH:
         if (StreamMode == DAB)
            lcd.print("Search DAB+ sations    ");
         else
            lcd.print("Search for FM station  ");
         delay(1000);
         break;
      case VOLUME:
         lcd.print("Volume set                ");
         delay(1000);
         break;
      case SOUND:
         lcd.print("Equalizer                 ");
         delay(1000);
         break;
         }
      lcd.blink(); 
ShowSignalStrength();

}


//--------------------------------------------
//
// SETUP
//
//--------------------------------------------

void setup() {

lcd.begin (40,4);

lcd.createChar(0,antenna);
   

pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,INPUT_PULLUP); // OnOff key
pinMode(5,INPUT_PULLUP); // Mode key
pinMode(6,INPUT_PULLUP); // Enter key

digitalWrite(2,LOW);
digitalWrite(3,LOW);
lcd.clear();
lcd.setCursor(13,2);
lcd.print("DAB+ Power OFF");
Serial.begin(57601);
Serial.setTimeout(5); 
delay(1000);
}


//-------------------------------

void TimeOutSet() {

TimeOut = true;
}

//-----------------------
// Sound
//-----------------------

void ChangeEqualizer() {

int soundchange = 0;
int response = 0;


lcd.clear();
lcd.setCursor(10,1);
lcd.print("S O U N D :   ");
lcd.setCursor(25,1);
switch (Sound) {
   case BASSBOOST :
      lcd.print("BASSBOOST");
      break;
   case JAZZ :
      lcd.print("JAZZ     ");
      break;
   case LIVE :
      lcd.print("LIVE     ");
      break;
   case VOCAL :
      lcd.print("VOCAL    ");
      break;
   case ACOUSTIC :
      lcd.print("ACOUSTIC ");
      break;
   }
lcd.setCursor(0,3);
lcd.print("Draai aan knop, wanneer OK, wacht dan.");

// in this mode, the rotary switch is used to change Equalizer settings, so ENTER key could not be scanned.
// Therefore a timer interrupt is activated.
TimeOut = false;

while (TimeOut == false) {
   MsTimer2::set(2000,TimeOutSet);
   MsTimer2::start();      
...

This file has been truncated, please download it to see its full contents.
Liquid display libraryArduino
library for 4X40 lcd
No preview (download only).
used rotary encoder libraryArduino
No preview (download only).

Schematics

Datasheet Bourns rotary encoder
LCD datasheet
Interfaceboard
Connections for lcd and rotaryswitch

Comments

Similar projects you might like

Konica Minolta MFP Touch screen use with Arduino Uno

Project showcase by Team DoubleG

  • 700 views
  • 0 comments
  • 4 respects

Nextion LCD communicate with Arduino UNO

by Tamer Savaşcı

  • 25,991 views
  • 8 comments
  • 14 respects

Air Quality Check with Arduino Uno

by AMAL NS

  • 16,371 views
  • 2 comments
  • 40 respects
Add projectSign up / Login