еще один бенддекодер для ICOM
https://forums.qrz.com/index.php?threads/icom-arduino-band-voltage-decoder.702126/Modded from
http://www.5b4wn.com/main/a1921.htmlUsing an ULN2803A Darlington array for relay driving. 2 spare Darlington pairs will key amp (160M & 30M)
Here's the sketch.
Ed
//icom band decoder
//Marios Nicolaou 5B4WN (c) 2009 7 24
//Use the code at your OWN risk
//GPL licence
//Modified by Ed Grafton WA4SIX
//Mod is to directly select pin, instead of BCD
int icomBandPin = 5; // select the input pin for the potentiometer
//int realVoltage = 8; // variable to store the value coming from the sensor Volts
int sensedVoltage=0;
int H=5;
int G=6;
int F=7;
int E=8;
int D=9;
int C=10;
int B=11;
int A=12;
float calculatedVoltage=0;
int band=0;
int counter =0;
int previousValue=0;
void setup() {
Serial.begin(9600);
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(H, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensedVoltage = analogRead(icomBandPin);
//get 5 consecutive values
// counter++;
if (counter==5) {
calculatedVoltage = float(sensedVoltage)*5/1024;
Serial.print (sensedVoltage);
Serial.print (" - ");
Serial.print (calculatedVoltage);
Serial.print (" - ");
band=getBand(calculatedVoltage);
Serial.println(band, DEC);
delay (20);
} else {
if (abs(previousValue-sensedVoltage)>10) {
//means change or spurious number
previousValue=sensedVoltage;
} else {
counter++;
previousValue=sensedVoltage;
}
}
}
int getBand(float voltage) {
int band=0;
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
digitalWrite(H, LOW);
if (voltage>4.20 && voltage<4.68) {
band=160;
digitalWrite(A, HIGH);
} else if (voltage>3.50 && voltage<4.20) {
band=80;
digitalWrite(B, HIGH);
} else if (voltage>=2.95 && voltage<3.50) {
band=40;
digitalWrite(C, HIGH);
} else if(voltage>=2.30 && voltage<2.95) {
band=20;
digitalWrite(D, HIGH);
} else if (voltage>=1.70 && voltage<2.30) {
band=15;
digitalWrite(E, HIGH);
} else if (voltage>=1.2 && voltage<1.7) {
band=10;
digitalWrite(F, HIGH);
} else if (voltage>=0.75 && voltage<1.2) {
band=6;
digitalWrite(G, HIGH);
} else if (voltage <0.75) {
band=30;
digitalWrite(H, HIGH);
}
return band;
}