Sorry for cryptic title, don't really know how to describe my problem. I've tried various methods.
I have code which takes input from the keypad as a char array. I need to convert this to a uint32 to then change a vfo frequency module.
This is a sample code I made up but it doesn't work as I expected. On the serial monitor I can see the char input and also the next ASCII representation of the 'vfo'.
Comments in code show my points where I am checking to see whats actually happening.
'vfo' needs to pass to another display frequency routine. This should be an 8 digit figure i.e. 14235000
I would like to limit the input to 8 characters.
Thanks for any pointers.
uint32_t vfo
uint32_t freq_n;
void readKeypad()
{
char key = keypad.getKey();
if (key != NO_KEY)
{ lcd.print(" "); // clears top line only, to show input from keypad
new_freq[z]=key;
z++;
lcd.setCursor(1,0);
lcd.print(new_freq); // echo to lcd
switch(key)
{
case '*': // if star is entered then process
freq_n = atoi(new_freq);
Serial.print(new_freq); // echo to monitor
vfo = (freq_n); // set vfo as frequency
Serial.print(vfo); // shows ASCII string ??
z=0; // reset array count
display_frequency(); // display frequency
display_band(); // display band
delay (5000); // pause to see what's happening
for( int i = 0; i < sizeof(new_freq); ++i ) // clear array
new_freq[i] = (char)0; //
break;
case '#': // clear and resume
z=0;
for( int i = 0; i < sizeof(new_freq); ++i ) // clear array
new_freq[i] = (char)0; //
display_frequency(); // return to normal
display_band();
// lcd.print(" ");
break;
}
}
}