LAB 5 Page 1
NAME: _______________________________ STUDENT ID #: ______________________________

LAB 5: AnalogIn, AnalogOut, and Class Members

LAB SECTION: A B C D E F G H I J K L M N O P
OBJECTIVES:
class member functions to get POT values and display them on the Putty screen.
2. To understand THERMISTORS - the types and how the GROVE Temperature sensor is used to
determine temperature on an Arduino.
3. To be able to create an MBED version of the temperature program to display temperature values in
Celsius and Fahrenheit on the Putty Screen.
Procedure:
1. Click on THIS LINK and import the program into the MBED compiler and get it working.
In the LAB 5 quiz, state how many errors that you had to correct in this question to get this code working.
LAB 5 Page 2
2. Click on THIS LINK to get code to MBED compiler. Compare imported code to code shown below:
Even though there are NO SYNTAX errors, how many lines of code need to be changed to make the program
work so that it gives proper values of your room temperature. Give your answer in LAB 5 quiz.
LAB 5 Page 3
3. After watching THIS VIDEO, fill in the chart below. Please remember to hold your thumb on the
Temperature sensor chip as you make these readings. Remember to set a break point as shown, and
then RUN each time to the break point in order to take your readings.

R _________________

R _________________

R _________________
From these readings, the value of R (increases/decreases) _______________ as the temperature
increases.
Based on this, the type of Thermistor used in the Grove Temperature Module has a
(PTC/NTC) ___________________
PTC= (Positive Temperature Coefficient)
NTC= (Negative Temperature Coefficient)
4. The first line of the code below gets a 16 bit unsigned value (0-65535) for the voltage and then uses
it in the second line of code to compute the Resistance.
voltage=input1.read_u16(); // gets 16-bit raw A/D value
R=65536.0/((double)voltage)-1.0;
You can also generate a float value for the voltage and use it to compute the Resistance as shown
below:
R=1.0/voltage1-1.0;
The advantage of using a float value for the voltage that returns a value from 0.0-1.0 is that you can
easily scale the voltage value to the actual voltage that you wish to read.
Since the maximum voltage is 3.33 voltage, we can multiply voltage1 by 3.33 to get the actual voltage
value for display purposes.
LAB 5 Page 4
5. In MCUXpresso, add the following two lines of code at the bottom of the while loop:
position(14,30);
printf(“Resistance is %5.2f Kohms”,R*100);
6. Terminate the program, then use the BLUE BUG button to compile and download the new version.
7. Remove the break point from your code, then RUN your program.
8. Now that you can see the RESISTANCE and TEMPERATURE being displayed on the Putty screen,
validate the following three statements by holding your finger against the temperature sensor.
As the Temperature Increases, the Resistance Decreases. YES / NO
The thermistor used in the Grove Temperature Sensor has a NTC YES / NO
When the temperature is 25.0 degrees celsius, the Resistance YES / NO
is approximately 100 K ohms