Yeasu bcd output not working correctly

I am having problems getting a arduino mega 2560 to output bcd (4bits) according to a certain frequency and band that is decoded from a Icom radio civ/cat data line .I can get the first 3 binaries to display correctly (led brightness ) but the last binary in the 4 bit string is always a problem regardless of in what state the other 3 are in ,i have replaced the led and still the same .I have not implemented optos or transistors as this is only a prototype i am building right now .I have even assigned other digital pins for the last binary from 22 and above,digital pins 2-13 but still the same .Could there be a problem in the coding that i have tried to add for the bcd- output and extra relays?
I know digital out is either on or off but will a very low lit led turn on a opto?
Please be kind as im learning as i go along .

*This is the partial code as the rest is way to long to put in here

if ((QRGcomp < High4)   and (QRGcomp > Low4))     BAND = 4;
  {
  digitalWrite(BCDAPin,0) ;
  digitalWrite(BCDBPin,1) ;
  digitalWrite(BCDCPin,0) ;
  digitalWrite(BCDDPin,0) ;
  }
  
  if ((QRGcomp < High6)   and (QRGcomp > Low6))     BAND = 6;
 {
  digitalWrite(BCDAPin,0) ;
  digitalWrite(BCDBPin,1) ;
  digitalWrite(BCDCPin,0) ;
  digitalWrite(BCDDPin,1) ; // this output never displays very bright 
  digitalWrite(Rly14Pin,1) ;
 }
 
  if ((QRGcomp < High10)  and (QRGcomp > Low10))    BAND = 10;
  {
  digitalWrite(BCDAPin,1);
  digitalWrite(BCDBPin,0);
  digitalWrite(BCDCPin,0);
  digitalWrite(BCDDPin,1); // this output never displays very bright 
  digitalWrite(Rly12Pin,1);
  digitalWrite(Rly13Pin,1);
  }
  
  if ((QRGcomp < High11)  and (QRGcomp > Low11))    BAND = 11;
  {
  digitalWrite(BCDAPin,1);
  digitalWrite(BCDBPin,0);
  digitalWrite(BCDCPin,0);
  digitalWrite(BCDDPin,1); // this output never displays very bright 
  digitalWrite(Rly11Pin,1);
  digitalWrite(Rly13Pin,1);
  }
  
  if ((QRGcomp < High12)  and (QRGcomp > Low12))    BAND = 12;
  {
  digitalWrite(BCDAPin,0);
  digitalWrite(BCDBPin,0);
  digitalWrite(BCDCPin,0);
  digitalWrite(BCDDPin,1); // this output never displays very bright 
  digitalWrite(Rly10Pin,1);
}
if ((BAND == 0 ));
  {
  digitalWrite(BCDAPin,0);
  digitalWrite(BCDBPin,0);
  digitalWrite(BCDCPin,0);
  digitalWrite(BCDDPin,0);
  digitalWrite(Rly1Pin,0);
  digitalWrite(Rly2Pin,0);
  digitalWrite(Rly3Pin,0);
  digitalWrite(Rly4Pin,0);
  digitalWrite(Rly5Pin,0);
  digitalWrite(Rly6Pin,0);
  digitalWrite(Rly7Pin,0);
  digitalWrite(Rly8Pin,0);
  digitalWrite(Rly9Pin,0);
  digitalWrite(Rly10Pin,0);
  digitalWrite(Rly11Pin,0);
  digitalWrite(Rly12Pin,0);
  digitalWrite(Rly13Pin,0);
  digitalWrite(Rly14Pin,0);
    clearindicator();                  // We are not on standard band, clear antenna's
 
  
  }

I have added a bcd chart from the internet bands 12 and up bcd no 4 is were the problem lies has the last part ..If band ==0 is the coding in that done correctly ?
Please excuse my vagueness on this any help would be appreciated.

image.jpg

This is the partial code as the rest is way to long to put in here

And, here's a partial answer.

For the complete answer, I'm sure that you can figure out what to do.

Would you like me to post all the code ? as its over 950 lines .. it would help but i cannot post to this forum using a zip file with all the code or in parts

Would you like me to post all the code ?

That depends. Would you like help? Same answer.

it would help but i cannot post to this forum using a zip file with all the code or in parts

Why not? Everyone else can? Use the Additional Options link to attach a file.

Clearly, a simpler sketch to validate the communication between the Arduino and the Yeasu is in order, though.

Hi,

One thing first:

if ((QRGcomp < High4)   and (QRGcomp > Low4))     BAND = 4;

That ENDS the IF with the ";" The following code in brackets runs EVERY time.

You need brackets after the IF statement containing everything you want to do in that situation...

Here is the code
After making the mods to the if statements 482-612 i get this error afterwards ..hope this helps

'clearindicator' was not declared in this scope

ic706_3_modified.ino (27 KB)

After making the mods to the if statements 482-612 i get this error afterwards

This error? What error?

After making the mods to the if statements 482-612 i get this error afterwards ..

How would i rewrite the if statement if i wanted everything in that statement to be done .. after adding the if statements i get

ic706_3_modified.ino: In function 'void setup()':
ic706_3_modified:307: error: 'clearindicator' was not declared in this scope
ic706_3_modified.ino: In function 'void loop()':
ic706_3_modified:411: error: 'clearindicator' was not declared in this scope
ic706_3_modified:420: error: 'clearindicator' was not declared in this scope
ic706_3_modified:431: error: 'clearindicator' was not declared in this scope
ic706_3_modified:440: error: 'clearindicator' was not declared in this scope
ic706_3_modified:609: error: 'clearindicator' was not declared in this scope
ic706_3_modified:648: error: 'clearindicator' was not declared in this scope
ic706_3_modified:665: error: expected initializer before 'lcd'
ic706_3_modified.ino: In function 'void ReadButtons()':
ic706_3_modified:919: error: 'clearindicator' was not declared in this scope
ic706_3_modified:932: error: 'clearindicator' was not declared in this scope
ic706_3_modified:946: error: 'clearindicator' was not declared in this scope
ic706_3_modified:959: error: 'clearindicator' was not declared in this scope

void clearindicator ()   // Clear all antenna
  lcd.setCursor(4, 1);

Missing opening brace

 if (QRGcomp < High4)   and (QRGcomp > Low4)     BAND = 4;{
  digitalWrite(BCDAPin,0) ;
  digitalWrite(BCDBPin,1) ;
  digitalWrite(BCDCPin,0) ;
  digitalWrite(BCDDPin,0) ;
  }

Can you guys help me out with this statement, if qrg comp is smaller than high4 and qrgcomp bigger than low4 make that = band 4 as well as set the bcd pins a -low,b-high,c-low,d-low
Thanks in advance

 if (QRGcomp < High4)   and (QRGcomp > Low4)     BAND = 4;{
  digitalWrite(BCDAPin,0) ;
  digitalWrite(BCDBPin,1) ;
  digitalWrite(BCDCPin,0) ;
  digitalWrite(BCDDPin,0) ;
  }

What do you want to have happen when the if statement evaluates to true? If the only thing that is to happen is that BAND is to be set to 4, that is what is happening now.

If the stuff in the curly braces is to be executed, too, move BAND = 4; inside, and move the { onto the next line.

In other words this should be the answer paulS?

  if ((QRGcomp < High4)   and (QRGcomp > Low4))
   {
  BAND = 4;
  digitalWrite(BCDAPin,0) ;
  digitalWrite(BCDBPin,1) ;
  digitalWrite(BCDCPin,0) ;
  digitalWrite(BCDDPin,0) ;
  }

:astonished:

In other words this should be the answer paulS?

Your code. Your hardware. Your call.

solved thanks