I'm trying to get a temperature sensor to read out in increments of 0.1 degree, and I also need it to display negative numbers.
I have done a search for example code but the inverse line below next to the ***does not work.... positive numbers come out ok but the negative readings just show 0.0
I'm using an 08M
What is a good way to do an inverse function on a lowly 08M?
I have done a search for example code but the inverse line below next to the ***does not work.... positive numbers come out ok but the negative readings just show 0.0
I'm using an 08M
What is a good way to do an inverse function on a lowly 08M?
Code:
main:
symbol pinx = 4
symbol temp = w1
symbol whole = b4
symbol deci = b5
symbol signr = 0
readtemp12 pinx,temp
b6 = 43 ; ="+"
IF temp> 2048 THEN ; below zero...
b6 = 45 ; ="-"
temp = 1/ temp ; ****************this is the problem
temp = temp AND 4095 + 1 ;mask off top 4 bits,add 1 for correction
ENDIF
temp = temp*10 / 16 ; x10 = 1 decimal(0.1) resolution
whole = temp / 10
deci = temp // 10
serout 0,n2400,(b6,#b4,".",#b5,13,10)
goto main