So are you saying I need to write it as int totalnumofcoils;// calculated ?
That makes more sense that does ignoring the fractional part of a float.
I don't understand the use of sprintf() . Is that part of Software.Serial.h library?
No, and I'm sure didn't suggest that it was.
Can you be more specific as to how to use sprintf()?
No, that is YOUR part of the project. I'm not certain that sprintf() can format the number the way you want. But, once you have a string, modifying the string to add a comma n places from the end is child's play.
robinhosler:
I'm writing a program, that generates a number, and prints it to the Serial Monitor.
The number is displayed as... Total Number Of Winds = 17040.
I'd like to have the number have a comma in it so it looks like 17,040.
I've tried everything I can fined, but I'm new to programing.
You want a "thousands seperator" and not a "decimal komma", correct?
You can decide whether the number is 1000 or more ==> format using thousands seperator ','
Or if number is less than 1000 ==> normal formatting
Formatting depends on the actual number format.
Here is an example if "winds" is a "long":
long winds=17040;
char buf[21];
if (winds>=1000)
snprintf(buf,sizeof(buf),"%ld,%03ld",winds/1000,winds%1000);
else
snprintf(buf,sizeof(buf),"%ld",winds);
Serial.println(buf);
Edit: Code example works for positive numbers only. Do you need negative numbers, too?
I programmed, in BASIC, back in the 80's, and I'm learning the Arduino code. So I have a clue, but a lot of my "old" knowledge is hard to retrieve from my brain.
ENTER Wire Gauge .................. = 40
ENTER Pole Diameter .............. = 0.2500
ENTER Outer Pole Centers ......... = 2.1250
Diameter Of Wire ................. = 0.0031
Resistance Per 1000ft. ........... = 1049
Apx. Total Length / Ft. .......... = 7150
Avg. Length Of Wrap / In. ........ = 5.035
Because, in the end, only the four lines of input, and Total Number Of Winds data will be displayed. The rest of the data is only being displayed temporarily, so I can check it's accuracy.
The program is going to run a pickup coil winder, to make guitar pickups.