Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 23:35 27 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Displaying 2 DS18B20s

Author Message
Desw
Newbie

Joined: 20/02/2017
Location: Australia
Posts: 5
Posted: 09:00pm 27 Feb 2017
Copy link to clipboard 
Print this post

I cannot work out how to display 2 DS18B20 at the same time.1 is connected to pin16 the other to pin18.How do you give them seperate strings so they can be displayed seperately.
The code Im using is DS18B20$=(TEMPR(16))
Thanking you for your help
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:21pm 27 Feb 2017
Copy link to clipboard 
Print this post

Temp1$=TEMPR(16)
Temp2$=TEMPR(18)

Regards
Jman
 
Desw
Newbie

Joined: 20/02/2017
Location: Australia
Posts: 5
Posted: 12:39pm 28 Feb 2017
Copy link to clipboard 
Print this post

I dont know wot Im doing wrong but I keep getting error: Expecting a string with this code
Love New Zealand have been there 2 times People very friendly
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 12:55pm 28 Feb 2017
Copy link to clipboard 
Print this post

You have to convert the numerical value returned by TEMPR() to a string

Temp1$=STR$(TEMPR(16))
Temp2$=STR$(TEMPR(18))

If you want to display with a fixed number of decimal places, STR$() has options for that.

Jim
VK7JH
MMedit   MMBasic Help
 
skylight
Newbie

Joined: 10/01/2016
Location: United Kingdom
Posts: 23
Posted: 04:02am 02 Mar 2017
Copy link to clipboard 
Print this post

If you wish to leave the result as a number,to perform maths on for conversion from centigrade to Fahrenheit for instance:

PRINT "Temperature in Degrees C = " TEMPR(16)
PRINT "Temperature in Degrees C = " TEMPR(18)

The result x1.8+32 gives the temperature in Fahrenheit.

Remember if there is an error in measurement the device will return 1000
so the above formula may give a ridiculous temperature result occasionally, you would need to code to ignore those errors.Edited by skylight 2017-03-03
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024