I have a test sketch that I have been working on and I need some advice from the Arduino pro's here on the form. What I'm trying to do is take the freq number (ex: 6000) and have it display as 146.000. The 14 and . are hard coded because that will never change. The problem I'm having is when the channel number is 401 (6005) It shows up at 146.00 (last digit is missing). I have done a lot of research on the net but, I have not come up with any information that is helpful. I wanted to ask the group here if you could give me some advise on what I'm doing wrong. Thank you
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
#define uint16 unsigned int
#define uint8 unsigned char
unsigned long Channel;
void setup(){
lcd.begin(20, 4); //VFD display 20 x 4
Channel = 400; //Set for 146.000
}
void loop(){
uint16 freq;
//Calculate actual frequency
freq = Channel*5 + 4000;
//Write frequency to display
first_line();
lcd.print("14");
lcd.print((uint8)(freq / 1000));
lcd.print(".");
lcd.print((uint8)((freq / 100) % 10) + "0");
lcd.print((uint8)((freq / 10) % 10) + "0");
lcd.print((uint8)(freq % 10) + "0");
}
void first_line() //Sets LCD to first line
{
lcd.setCursor(0, 0);
}