restore an enum value

Hello,

How to restore a variable with an Enum value?

enum sources_t { NO_SOURCE, TV, IPOD, RADIO, CD} sourceIn;
const char  sourcesText[6][6] = {"?", "TV", "iPod", "RADIO", "CD"};

uint8_t oldSourceIn;


void setup()
{
  sourceIn = CD;
  oldSourceIn = RADIO;
}

void loop()
{

Serial.print (sourcesText[sourceIn]);
  sourceIn = oldSourceIn;  //I would like that sourceIn is loaded with RADIO value
  
}

Thanks

To print out through Serial you must initialize the port with

Serial.begin(baud);
enum sources_t { NO_SOURCE, TV, IPOD, RADIO, CD} sourceIn;
const char  sourcesText[6][6] = {"?", "TV", "iPod", "RADIO", "CD"};

uint8_t oldSourceIn;


void setup()
{
   Serial.begin(9600);
   sourceIn = CD;
   oldSourceIn = RADIO;
   Serial.print("before ");
   Serial.print (sourcesText[sourceIn]);
   sourceIn = oldSourceIn;  //I would like that sourceIn is loaded with RADIO value
   Serial.print("    after ");
   Serial.println(sourcesText[sourceIn]);
}

void loop()
{
   
}

Please post a complete sketch that shows what you are trying to do

Most of the code that you have posted makes no sense at all

oldSourceIn should be declared as sources_t, not uint8_t, that will eliminate the warning message.

david_2018:
oldSourceIn should be declared as sources_t, not uint8_t, that will eliminate the warning message.

Perfectly what I was looking for!!
Thanks