Hi, welcome to the forum.
Next time, please show us the whole sketch between [code] ... [/code] tags.
void setup() {
Serial.begin (9600);
Serial.println ("\nEnter Celsius, you get Fahrenheit");
}
void loop() {
float temp;
float f; // Declared and Initialized
while (Serial.available() ==0); // looking for input
temp = Serial.parseFloat(); // Received value
f = (temp * 9.0 / 5.0) + 32.0; // do math
Serial.println(f); // Show Results
}
Use Serial,println() to show yourself more of what is happening. For example put in Serial.println(temp); so you can be sure the number is being received correctly.
You'll get better results if you follow these guidelines about posting your code:
Post code. You did that; good job.
Post a complete sketch. I should be able to copy your code into the IDE, and have it compile. This code is a snippet - part of a program that won't compile without some additional lines. If you post a complete sketch, a reader can copy, paste and try it without a whole lot of effort. If you don't, at least some readers will skip to the next post, and won't respond to yours.
Post the smallest sketch you can come up with that illustrates the problem you've encountered. It's important to post a complete sketch, but it's also important to isolate the issue to a small, easily readable sketch. If the code is too long and complex, a reader may again skip to the next post. Your snippet, and the code that I can extrapolate around it, isn't long or complex. But, if you stay with this activity long enough, one day it will be, and you'll get more and better answers if you're willing to isolate the issue to a small sketch.
Post your code in [ code ] tags. Here's a description of how to do that: http://forum.arduino.cc/index.php/topic,148850.0.html. See item #7. As a new poster to this forum, you'd do well to read the whole thing. This information is accessible from first sticky post, at the top of the first page of any section of the forum. As for code tags, they tell the server's software to display each character exactly as it is, rather than interpret some strings of characters as special characters, or display instructions. That ensures that your code shows up correctly, and isn't garbled.
Some of that has already been said in this thread. I think that repeating it won't hurt anything. Please note that, for any of these guidelines that you might not have followed in your initial post, no apologies are necessary, expected, or even desired.
Looking at your code, here's what I see right away: something is peculiar about this line: float temp;, c;It looks like there's an extra character in the declaration. That may be an artifact of not using code tags, but intuitively it looks like real code. That line gives a compiler error, leading me to believe that this code wasn't copied directly from a sketch that compiled and ran. It's important that the code you post is precisely the code you used; otherwise, everybody wastes time solving problems that don't exist in your actual sketch.
Looking further, I don't see that variable c ever gets a value. Yet, it's used in this calculation: f= (c*9)/(5)+32; //do mathDid you meant to reference variable temp in this calculation, rather than c?
I'll comment on the comment in this line:float f ; // Declared and InitializedVariable f is local to loop(). Local variables aren't initialized when they're declared. They have a value that depends on whatever was already in their memory location - it could be anything. The comment doesn't affect your sketch, but it suggests that you expect these local variables to be initialized, and they aren't.
Finally, I'll note that Serial.parseFloat() takes characters that make sense as a floating point number - digits, decimal point, minus sign, and plus sign. It leaves any other character it finds in the buffer. If your serial monitor is set up to send a newline or carriage return, then the next time loop executes it will find that character in the buffer, try to parse a float from it, and return a zero. I would expect that you'd see the program print a "32" as a second line for each entry. You can set the serial monitor to send nothing after the input, and that will work. Or, you can use Serial.peek() to look at the buffer, and then read characters off the buffer until the first character is something that makes sense as a float.