¿ªÔÆÌåÓý

Re: New user


 

Mike,

There is nothing of mine in there.? I started with Ron's (PA3FAT) sketch which has the encoder?stuff and removed the s meter code.?All I did was comment out the smeter and bargraph functions in the loop. ?/g/BITX20/files/Radruino%20with%20rotary%20encoder%20and%20S-meter


Then I added Don's (ND6T) hardware mod and code for the voltage measurement which I tweaked to run every two minutes as it was ticking each time it ran - I haven't bothered to sort out the tick.

This goes in the definitions:

#define TWOMIN (1000UL * 120)? // two minutes

unsigned long rolltime = millis() + TWOMIN;? // variable to test against millis() in the loop



This goes in the loop:

if((long)(millis() - rolltime) >= 0) {?? //checks to see if its time to read the supply voltage again
?? float supply = (analogRead(A1));? // read the supply voltage
?? float voltage = supply/50.6;? // follow Don's method to determine the denominator
?? float volts = round(voltage*100)/100; // I only wanted one decimal point
?? lcd.setCursor(0,1);
?? lcd.print(voltage,1); lcd.print("V");
rolltime+=TWOMIN; // add two minutes to the rolltime variable to test against for next time.

}

As its currently set up the voltage is tested for the first time only after two minutes after power on.?I'm sure it could be rewritten to test immediately. I haven't bothered with it yet.


Happy to load it up in full but I would like to clean it up a bit, I'm a lazy coder and cut and paste a lot of stuff without commenting and also take shortcuts like commenting out bits I don't need. There are also some other lazy tweaks that I've done to personalise it to my preferences which again are not well formed code, but work as quick hacks.


Also, there is no crediting in there for the bits I've brought in so I'd like to make sure that's good too.


Regards



Simon





Join [email protected] to automatically receive all group messages.