Definition of Tutorial: A tutorial is a step-by-step teaching guide designed to help someone "learn how to do something", usually by explanation and examples.
Figure-1: Schematic of Temperature Meter
1. VDT = DC voltage from signal pin of LM35 when room temp is T degC
2. Find relationship between T and VDT from response points of LM35 given in Fig-1:
T = 100 * VDT
3. Function to set full scale of ADC at 1.1 V: (Full scale is the maximum input signal which, when applied to an ADC channel, causes all output bits of the ADC to become 11 1111 1111.)
analogReference(INTERNAL);
4. Create/prepare Lookup Table (LUT) showing cc-codes for the digits 0 to 9 and A to F. The C++ declaration code for this LUT is given below Fig-2:
Figure-2:
byte lupTable[] =
{
0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, //0 1 2 3 4 5 6 7
0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71 //8 9 A B C D E F
};
5. Acquire VDT signal from sensor and save its binary form into variable y.
int y = analogRead(A4);
6. Find relationship between T and y.
T = 100 * (1.1/1023) * y; //T = 25.3
7. Convert T from float type to int type to make it compatible with display unit which accepts fixed number (no floating point number). (The decimal point is inserted manually.)
int myT = (int) T * 10.0; //21.5 * 10.0 = 253.0; myT = 253 = d0 d1 d2
8. Extract decimal digits (d0 d1 d2 = 2 5 3) from myT and save them in an array.
byte myDigit[3];
int i = 2;
do
{
myDigit[i] = myT % 10; //myDigit[2] = 00000011 = 3
myT = myT/10;
i--
}
while(myT != 0);
9. Collect cc-code for the digits d0 d1 d2 from LUT and save them in variables:
byte ccd0 = lupTable[myDigit[0]]; //cd0 = 0x5B for 2
byte ccd1 = lupTable[myDigit[1]]; //ccd1 = 0x6D for 5
byte ccd2 = lupTable[myDigit[2]]; //ccd2 = 0x4F for 3
10. Send ccd0 onto DP0 position of display unit.
PORTB = ccd0; //PORTB accpets lower 6-bit (segemnts: a to f) of ccd0
digitalWrite(6, bitRead(ccd0, 6)); //DPn-6 accepts bit-6 (g segment) of ccd0
digitalWrite(7, bitRead(ccd0, 7)); //Dpin-7 accepts bit-7 (. segment) of ccd0
//-----------------------
digitalWrite(A0), HIGH); //2 appears only on DP0 postion
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);
//------------------------
delay(5)
//===============================
11. Send ccd1 and ccd2 onto DP1 and DP2 positions of the display unit respectively
12. Open IDE, place the above codes under the appropriate places, write any missing codes, compile, and upload into UNO R3. Check that Display Unit shows room temperature at 1 sec interval.
13. Exercise
Re-write sketch of Step-12 using SevSeg.h Library to reduce number of code lines.





