I am a little new to Arduino, but I Have done a good amount of other programming. I am a ham radio operator, and I have directional antennas that I need to rotate. I have an old rotator that I am upgrading to use my arduino as a digital controller for it. I will only include the code that I believe is relevant to my issue because I know how painful it is to look through 1000 lines of someones code trying to find what is needed. What I want to do is press my "CALIBRATE" button and then let go of the button, and let my CalibrateFunction() run until one of my position switches goes to HIGH. right now, it works as long as I hold the button down. The purpose of this is to spin my rotator clockwise (CW) until one of the four position sensors is tripped(North, East, South, West) that will stop the calibration function and the rotator will stop moving. I know I will need to debounce the switch, but first I want to get the function to run after I let go of the CALIBRATE button. Here is my code
void loop() {
CALVAL = digitalRead(CALIBRATE); //Check the position of the calibrate switch and assign it to the variable
if (CALVAL == HIGH){
CalibrateFunction();
}
}
int CalibrateFunction(){ //Calibration Function first checks to see if one of the four calibration switches is high, and if not
//sets the rotator into a clockwise motion until one of the calibration switches is switched High.
VALN = digitalRead(N); //Check if the position switch is high or low and assign value to variable
VALE = digitalRead(E); //Check if the position switch is high or low and assign value to variable
VALS = digitalRead(S); /Check if the position switch is high or low and assign value to variable
VALW = digitalRead(W); //Check if the position switch is high or low and assign value to variable
if ((VALN != HIGH) & (VALE != HIGH) & (VALS != HIGH) & (VALW != HIGH)){ //Check if the position switch is high or low
digitalWrite(CW, HIGH);
}
There is more code, but for the most part, it is not relevant to the issue. thanks in advance.
Jake
KD7VEA