Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By ptribbey
#60348 This takes a variable such as temp(0), and uses the expected value (60-90 in this case) and maps it to another value, in this case 200 to 100. I used the existing graphing example, modified for a DS18B20.
I suppose in this case you could map 300 to 0, to fill the graph.
I want to thank the developers. This is the most fun with gadgets I've had since the Arduino.

Code: Select allmemclear
graphics 300,300
timer 1000, [doit]
[top]
x = 0

InMin=60        'expected low input
InMax=90       'expected high input
OutMax=100   'desired max output
OutMin=200    'desired min output
' in this case, 60 maps to 200 and 90 maps to 100.

gcls
text 10,100,"DS18B20",180 + 90
text 100, 250, "Time (1 second)",0
wait


[doit]
y = temp(0) ' read the 1wire sensor on pin 2
z = (y*9)/5+32 ' C to F conversion
aOLD = a
a = (z-InMin)*(OutMax-OutMin+1)/(InMax-InMin+1)+OutMin 'where the MAPping is
xOLD = x
x = x + 10
line xOLD,aOLD,x,a,5
if x > 300 then goto [top]
wait