Jack Hansdampf / Mbed OS Temperatursever_TI4

Dependencies:   LCD_i2c_GSOE

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  */
00005 
00006 #include "mbed.h"
00007 #include "LCD.h"
00008 
00009 
00010 // Blinking rate in milliseconds
00011 #define BLINKING_RATE     500ms
00012 BufferedSerial hc05(PB_10,PB_11,9600);
00013 AnalogIn ain2(PA_4);
00014 
00015 lcd mylcd;
00016 
00017 int main()
00018 {
00019     char daten[15];
00020     
00021     float Wert = 0; // variable to store the value read
00022     float R2_25 =1500;
00023     float R2_theta;
00024     float R1=1500;
00025     float dt;
00026     float t;
00027     float alpha=-0.045;
00028 
00029     // Initialise the digital pin LED1 as an output
00030     DigitalOut led(LED1);
00031     mylcd.clear();
00032     mylcd.cursorpos(0);
00033     while (true) {
00034         led = !led;
00035         R2_theta=R1*ain2/(1-ain2);
00036         dt=(R2_theta/R2_25-1)/alpha; //näherungsweise
00037         t=25+dt;
00038         sprintf(daten,"*G%d*",(int)t);
00039         hc05.write(daten,12);
00040         sprintf(daten,"*T%d*",(int)t);
00041         hc05.write(daten,12);
00042         mylcd.cursorpos(0);
00043         mylcd.printf("%s",daten);
00044         ThisThread::sleep_for(BLINKING_RATE);
00045     }
00046 }