simplifying a formula

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;

mjpcarbon

Posts: 435
Joined: Fri Nov 29, 2013 8:57 pm

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.

Posts: 81533
Joined: Sat Feb 07, 2009 10:11 am

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?

Code: Select all | TOGGLE FULL SIZE
objta = ( objt * 1.8 ) + 32;
Serial.print( objta );
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

Posts: 63053
Joined: Thu Feb 11, 2010 2:51 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)

mjpcarbon

Posts: 435
Joined: Fri Nov 29, 2013 8:57 pm

Re: simplifying a formula

What are the data types of the variables involved?

Posts: 81533
Joined: Sat Feb 07, 2009 10:11 am

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
Code: Select all | TOGGLE FULL SIZE
objta = ( objt * 1.8 ) + 32;
Serial.print( objta );
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

mjpcarbon

Posts: 435
Joined: Fri Nov 29, 2013 8:57 pm

Re: simplifying a formula

Bill when you say variable, I am unsure of what you mean.

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.

Floating point variables have decimal places. Intgers do not. When you mix them together in calculations, things often get lost in the translation.

Posts: 81533
Joined: Sat Feb 07, 2009 10:11 am

Re: simplifying a formula

understood, I had turned it into an integer thus losing the decimal

mjpcarbon

Posts: 435
Joined: Fri Nov 29, 2013 8:57 pm