Me again I would like to simplify a small formula to keep a sketch clean but once again cannot accomplish it
I would like this be be true Serial.print((objt * 1.8 )+32) = objta;
simplifying a formula
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: simplifying a formula
Not sure what you are trying to accomplish there. Maybe if you showed us the relevant parts of what you have now for context.
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: simplifying a formula
It looks like you're trying to do a Celsius-to-Farenheit conversion, but as you've written the statement you're trying to assign a value to the function Serial.print().
Is this closer to what you wanted?
Is this closer to what you wanted?
Code: Select all
objta = ( objt * 1.8 ) + 32;
Serial.print( objta );
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: simplifying a formula
Yes that works like I wanted. again thank you
One curious thing, by doing this I lost the 2 decimal places in Serial Monitor( it doesnt matter but I am curious why)
One curious thing, by doing this I lost the 2 decimal places in Serial Monitor( it doesnt matter but I am curious why)
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: simplifying a formula
What are the data types of the variables involved?
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: simplifying a formula
Bill when you say variable, I am unsure of what you mean.
The tmp006 is reading temp and works great, just curious when I added the I lost the decimal places. Again it doesnt matter I just wanted to know why
I am also excited to receive the LCD screen I just ordered to see if I can display the temp
The tmp006 is reading temp and works great, just curious when I added the
Code: Select all
objta = ( objt * 1.8 ) + 32;
Serial.print( objta );
I am also excited to receive the LCD screen I just ordered to see if I can display the temp
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: simplifying a formula
objta and objt are variables (as far as I can tell). But you haven't showed us enough of your code to know what type of variables they are.Bill when you say variable, I am unsure of what you mean.
Floating point variables have decimal places. Intgers do not. When you mix them together in calculations, things often get lost in the translation.
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: simplifying a formula
understood, I had turned it into an integer thus losing the decimal
Please be positive and constructive with your questions and comments.