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.