Page 214 - ARM Based Microcontroller Projects Using MBED
P. 214
200 8. INTERMEDIATE LEVEL PROJECTS
/*************************************************************************
DIGITAL THERMOMETER
===================
This is a voltmeter program. Input analog voltage is applied to analog
input ADC1/0 (GPIO pin PA_0) of the Nucleo-F411RE development board.
The program reads and displays the analog voltage in millivolts on the
PC screen
Author: Dogan Ibrahim
Date : August 2018
File : TMP36
**************************************************************************/
#include "mbed.h"
Serial MyPC(USBTX, USBRX);
AnalogIn ain(PA_0);
// Clear the screen
//
void clrscr()
{
char clrscr[] = {0x1B, '[', '2' , 'J',0};
MyPC.printf(clrscr);
}
//
// Home the cursor
//
void homescr()
{
char homescr[] = {0x1B, '[' , 'H' , 0};
MyPC.printf(homescr);
}
//
// Goto specified line and column
//
void gotoscr(int line, int column)
{
char scr[] = {0x1B, '[', 0x00, ';' ,0x00, 'H', 0};
scr[2] = line;
scr[4] = column;
MyPC.printf(scr);
}
int main()
{
double mV, T;
clrscr(); // Clear the screen
homescr(); // Home teh cursor
MyPC.printf("\n\rDIGITAL THERMOMETER"); // Heading
MyPC.printf("\n\r===================");
FIG. 8.65 Program listing.
(Continued)