VMM501
V. 01 – 17/01/2019
18
©Velleman nv
Drag and drop the
analog read pin
block next to the
map/from
low/from high/to low/to high
block and set the
to high
value 4 to
3300.
Now, we drag and drop a
set item to
block under the first block. Change
the variable
item
to
vol
via the arrow.
The measured voltage in mV via
analog read pin
P0
is an 8-bit value of 0-
1023 (0-3.3 V) and is mapped from a low value (0 or 0 V) to a high value
(3300 mV or 3.3 V). The measured voltage (mV) is saved in the
vol
variable.
Now, we write a formula to convert the measured voltage into a
temperature:
𝑇𝑒𝑚𝑝𝑒𝑟𝑎𝑡𝑢𝑟𝑒 (°𝐶) =
(Output voltage (mV) − 500)
10
In this formula, the output voltage is the
vol
variable (measured through
the TMP36 sensor). The result of the formula will be saved in the
tem
variable.
Let’s write the formula with blocks. Drag and drop the
mathematical
function divide
over the 0 value of the
set vol to
block.