0

I don't have any code for this yet but I would like some ideas on coding it. I have a directional antenna that is rotating at a slow speed and a ham radio connected to the antenna. I have an output port on the radio that will put a voltage out from 0 to 5 volts for signal strength. I also have the rotational degree data that is captured. The question I have is do I try to do a long if then else statement to capture the 3 highest voltages and directions as variables for later processing or is there a better way. An example would go a long way as well.

  • you need to think about what you are asking .... radio signal strength varies almost continuously ... the three highest voltages could come from only one source – jsotola Oct 17 '18 at 1:24
  • That is true, That would be ok until I got closer with my vehicle where there would be more separation with the micro transmitters. If the 1st, 2nd and 3rd highest signals were the same bearing, that would actually be a bonus because I would know the transmitters were further away. When I get closer they would separate. – Bkukuk62 Oct 17 '18 at 4:37
  • do you know how to read the analog pin in Arduino sketch? I am sure you do. The rest of your question is about common coding in C++, so take a coding course, if you don't know how to code what you want – Juraj Oct 17 '18 at 6:47
0

It needs a bit more work but I would suggest using arrays to store the signal and positions something like this.. From (G7WJD) EXPIRED!

#define signalPin A0
#define degreePin A1
int signalStrength;
// STORE DATA IN ARRAY
// 0 [strength, direction]
// 1 [strength, direction]
// 2 [strength, direction]
int signals[3][3]; 
int degree;
bool positionSavedFlag = false;
void setup() {

}

void loop() {
 signalStrength = analogRead(signalPin);
 degree = analogRead(degreePin);
 // comapare with previous data
 for (int x = 0; x < 3; x++) {
  // have we saved data for this position before?
  if (degree == signals[x][1]) {
    // yes
    positionSavedFlag = true;
    // is it stronger than previous signal at this position
    if (signalStrength > signals[x][0]) {
      // yes so save / update it
      signals[x][0] = signalStrength;
    }
  }
 }
 // now since position not already stored , store it

 }
  • Thank you Brian, this helps a beginner at coding very nicely. Kudos to you! – Bkukuk62 Oct 17 '18 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.