Re: Raduino error to solve
An easier way to write this would be:
/ ? ? Purpose: to change the increment value
? ? Argument list:
? ? ? ? int whichOne ? ? ? ?what is the current radix
? ? Return value: ? ? ? ? long ? ? ? ? ? ? ? ? ? ? ?the new increment value
/ long SetRadix(int whichOne) { ? long values[] = {1, 10, 100, 1000, 10000, 100000}; ? return values[whichOne]; }
A short program to exercise it is here. Enter anything at the Serial monitor and press the Send button to increment the counter.
long radix;
void setup() { ? Serial.begin(9600); ? Serial.println("Enter radix: "); }
void loop() { ? static int counter = 0; ? ?? ? if (Serial.available() > 0) { ? ? Serial.read(); ? ? counter++; ? ? if (counter > 5) { ? ? ? counter = 0L; ? ? } ? ? radix = SetRadix(counter); ? ? Serial.print("radix is now: "); ? ? Serial.println(radix); ? } }
long SetRadix(int whichOne) { ? long values[] = {1, 10, 100, 1000, 10000, 100000}; ? return values[whichOne]; }
Jack, W8TEE
toggle quoted message
Show quoted text
From: Toni Cossio <a.cossio@...> To: [email protected] Sent: Tuesday, June 6, 2017 7:19 PM Subject: Re: [BITX20] Raduino error to solve Vince, Many thanks, I will try with your directions. I hope this is the reason for the mistake. However the following is the final part:
// Button press changes the frequency change step for 1 Hz steps
?
? if (get_button())
? {
?
? switch (radix)
? {
? ? case 1:
? ? ? radix = 10;
? ? ? break;
? ? case 10:
? ? ? radix = 100;
? ? ? break;
? ? case 100:
? ? ? radix = 1000;
? ? ? break;
? ? case 1000:
? ? ? radix = 10000;
? ? ? break;
? ? case 10000:
? ? ? radix = 100000;
? ? ? break;
? ? case 100000:
? ? ? radix = 1;
? ? ? break;
? }
? display_radix();
}
}
73 de IV3XHM, Toni
|