Page 223 - ARM Based Microcontroller Projects Using MBED
P. 223

8.23 PROJECT 19—ON/OFF TEMPERATURE CONTROLLER           209
               /*************************************************************************

                                       ON/OFF TEMPERATURE CONTROLLER
                                       =============================
               This is an ON/OFF temperature controller program. The program reads the
               desired set-point temperature from the keyboard. A temperature sensor, a
               relay and heater are connected to the development board. If the measured
               temperature is above the desired set-point then the heater is turned OFF.
               If on the other hand the measured temperature is below the set-point
               temperature then the heater is turned ON. The program displays both the
               set-point and the measured temperatures on the PC screen.

               Author: Dogan Ibrahim
               Date  : August 2018
               File  : ONOFF
               **************************************************************************/
               #include "mbed.h"
               Serial MyPC(USBTX, USBRX);
               AnalogIn ain(PA_0);
               DigitalOut Relay(PC_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()
               {
            FIG. 8.75  Program listing.
                                                                                     (Continued)
   218   219   220   221   222   223   224   225   226   227   228