Antenna Controler fo HF Radio

Hello,

New to the forum and new to Arduino. I am trying to make a control box for my screwdriver antenna used for amateur radio. The control box is used to raise a lower the antenna along a loading coil to resonate the antenna on different frequencies.

I have used mem1 2 3 and so on in the sketch but would like to assign names to these locations to display on the LCD eg. mem1 would display 80M, it’s probably a simple thing to do for those with experience but for me it’s difficult.

Any help would be greatly appreciated. Code below

#include <SoftwareSerial.h>
#include <EEPROM.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);

const int DspPin = 0;
const int mem1 = 1;
const int mem2 = 2;
const int mem3 = 3;
const int mem4 = 4;
const int mem5 = 5;
const int mem6 = 6;
const int mem7 = 7;
const int mem8 = 8;
const int mem9 = 9;
const int mem10 = 10;

const int setBtn = 6;
const int upBtn = 7;
const int dnBtn = 8;

const int okBtn = 9;
const int clrBtn = 10;

const int reedSw = 12;

const int motor0 = A0;
const int motor1 = A1;
const int voltMeter = A2;

SoftwareSerial mySerial = SoftwareSerial(255, DspPin);
int turnsCount=0, lastTurnsCount=0;

long debounceButtonDelay = 50; // the debounce time; increase if the output flickers
long debounceReedDelay = 5; // the debounce time; increase if the output flickers
float voltageConstant = 0.004887585532746823; // multiply analog value by this to get input voltage

void EEPROMWriteInt(int p_address, int p_value) {
byte lowByte = ((p_value >> 0) & 0xFF);
byte highByte = ((p_value >> 8) & 0xFF);

EEPROM.write(p_address, lowByte);
EEPROM.write(p_address + 1, highByte);
}

unsigned int EEPROMReadInt(int p_address) {
byte lowByte = EEPROM.read(p_address);
byte highByte = EEPROM.read(p_address + 1);

return ((lowByte << 0) & 0xFF) + ((highByte << 8) & 0xFF00);
}

void resetMotor() {
digitalWrite(motor0, LOW);
digitalWrite(motor1, LOW);
return;
}

void motorUp() {
// wire 0 to +12v
digitalWrite(motor0, HIGH);
return;
}

void motorDown() {
// wire 1 to +12v
digitalWrite(motor1, HIGH);
return;
}

void updateDisplay() {
lcd.write(12);
lcd.print(“Antenna Ctrl”);
lcd.setCursor(0,0);
lcd.write(148);
lcd.print(" Antenna Position ");
lcd.setCursor(0,1);
lcd.print(turnsCount);
return;
}

void writeVoltage(float volts) {
lcd.write(12);
lcd.print(“Going up…”);
lcd.write(148);
lcd.print("Volts: ");
lcd.print(volts);
return;
}

void setup() {
lcd.init();
lcd.backlight();
lcd.begin(20, 4);
pinMode(DspPin, OUTPUT);
digitalWrite(DspPin, HIGH);
mySerial.begin(9600);
mySerial.write(12); // Clear
mySerial.write(22); // Cursor Off, No Blink
mySerial.write(17); // Turn backlight on
delay(5);
lcd.print(" Booting System …"); // First line
delay(1500);
lcd.print(" Please Wait …"); // First line
lcd.setCursor(0,1);
mySerial.write(13);
delay(6000);
lcd.clear() ;
lcd.print(“Screwdriver Antenna”); // Second line
lcd.setCursor(0,2);
mySerial.write(212); // Quarter note
mySerial.write(220); // A tone
lcd.print(" Controler"); // Third line
lcd.setCursor(0,3);
mySerial.write(212); // Quarter note
mySerial.write(220); // A tone
delay(2000); // show the boot message for a few seconds
lcd.clear() ;
lcd.setCursor(0,1);
lcd.print(" ??? ???"); // Fourth line

mySerial.write(212); // Quarter note
mySerial.write(220); // A tone
delay(2000); // show the boot message for a few seconds
lcd.clear() ;
pinMode(mem1, INPUT_PULLUP);
pinMode(mem2, INPUT_PULLUP);
pinMode(mem3, INPUT_PULLUP);
pinMode(mem4, INPUT_PULLUP);
pinMode(mem5, INPUT_PULLUP);
pinMode(mem6, INPUT_PULLUP);
pinMode(mem7, INPUT_PULLUP);
pinMode(mem8, INPUT_PULLUP);
pinMode(mem9, INPUT_PULLUP);
pinMode(mem10, INPUT_PULLUP);

pinMode(setBtn, INPUT_PULLUP);

pinMode(upBtn, INPUT_PULLUP);
pinMode(dnBtn, INPUT_PULLUP);

pinMode(okBtn, INPUT_PULLUP);
pinMode(clrBtn, INPUT_PULLUP);

pinMode(reedSw, INPUT_PULLUP);

pinMode(motor0, OUTPUT);
pinMode(motor1, OUTPUT);

updateDisplay();
}

void loop() {
int reedStat = digitalRead(reedSw);
int mem1Stat = digitalRead(mem1);
int mem2Stat = digitalRead(mem2);
int mem3Stat = digitalRead(mem3);
int mem4Stat = digitalRead(mem4);
int mem5Stat = digitalRead(mem5);
int mem6Stat = digitalRead(mem6);
int mem7Stat = digitalRead(mem7);
int mem8Stat = digitalRead(mem8);
int mem9Stat = digitalRead(mem9);
int mem10Stat = digitalRead(mem10);
int up = digitalRead(upBtn);
int dn = digitalRead(dnBtn);

int clr = digitalRead(clrBtn);

float voltage = analogRead(voltMeter);

// reed switch activated
if (reedStat == LOW) {
long start = millis();
while (digitalRead(reedSw) == LOW) { } // do nothing until releasing button
if ((millis() - start) > debounceReedDelay) { // only increase counter if reed actually hit
turnsCount++;
updateDisplay();
}
}
// up button pressed
if (up == LOW) {
long start = millis();
while (digitalRead(upBtn) == LOW) {
while ((millis() - start) <= debounceButtonDelay) { }
voltage = analogRead(voltMeter) * voltageConstant;
writeVoltage(voltage);
delay(500);

}

}

}

Do read the sticky on how to post code - so you don't get smilies.

Also it looks like you could do with arrays, as you're using numbers in your variables and later repeat code many times for them.