However I couldn't resist a quick physics experiment. Plug in the tft shield, and add a ds18 temperature sensor on pin A5 (the only one that shield leaves free!), and we an plot a graph of my coffee cooling!
Here's the code:
make ds18 device A5
make temperature number
make tft device
make tftX number
make tftY number
make tftColor number
make message string
when start
.set tftColor to 777
.tell tft to "clear"
.set tftColor to 700
.set tftX to 20
.set tftY to 100*3+20
.tell tft to "move"
.set tftY to 0*3+20
.tell tft to "draw"
.set tftX to 220
.tell tft to "draw"
.broadcast startMeasuring
.broadcast startDrawing
when startMeasuring
.forever
..tell ds18 to "start"
..wait 1 secs
..tell ds18 to "read"
..#say [ temperature ]
..set tftY to (temperature-40)*12+10
when startDrawing
.forever
..wait 1 secs
..set tftX to 0.25*timer+20
..tell tft to "setPixel"
Drawing the axis is the hardest part...
And here's the result:
It works! And we get something that's the beginnings of an asymptotic curve. If I'd left it longer it would have looked better, but then my coffee would be cold...
This code now works on Raspberry Pi too using the built in screen instead of the tft. Updated code for both Pi and Arduino are included in the examples folder of the Sniff Beta 4 download
ReplyDelete