Project done by Kristina.

Dependencies:   BSP_DISCO_F746NG LCD_DISCO_F746NG mbed

Committer:
TwistDragon
Date:
Mon Oct 15 11:52:09 2018 +0000
Revision:
0:68d9003ca160
Project.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TwistDragon 0:68d9003ca160 1 #include "mbed.h"
TwistDragon 0:68d9003ca160 2 #include "LCD_DISCO_F746NG.h"
TwistDragon 0:68d9003ca160 3
TwistDragon 0:68d9003ca160 4 DigitalOut ledRE(D2);
TwistDragon 0:68d9003ca160 5 DigitalOut ledGR(D7);
TwistDragon 0:68d9003ca160 6 DigitalOut ledBL(D6);
TwistDragon 0:68d9003ca160 7 DigitalOut ledIND(LED4);
TwistDragon 0:68d9003ca160 8 DigitalIn button(D3);
TwistDragon 0:68d9003ca160 9 LCD_DISCO_F746NG lcd;
TwistDragon 0:68d9003ca160 10 AnalogIn tempCalc(A0);
TwistDragon 0:68d9003ca160 11
TwistDragon 0:68d9003ca160 12 int main() {
TwistDragon 0:68d9003ca160 13 button.mode(PullUp);
TwistDragon 0:68d9003ca160 14 int prevValue = 0;
TwistDragon 0:68d9003ca160 15 //printf("Data transfer complete.\n");
TwistDragon 0:68d9003ca160 16
TwistDragon 0:68d9003ca160 17 while(1) {
TwistDragon 0:68d9003ca160 18 float temp = tempCalc.read()*27.21;
TwistDragon 0:68d9003ca160 19 printf("%f\n", temp);
TwistDragon 0:68d9003ca160 20 char result[18];
TwistDragon 0:68d9003ca160 21 snprintf(result, sizeof(result), "Current temp %f", temp);
TwistDragon 0:68d9003ca160 22 wait(0.1);
TwistDragon 0:68d9003ca160 23 if (button == 1 && prevValue == 0){
TwistDragon 0:68d9003ca160 24 if (ledRE == 1 && ledGR == 1 && ledBL && ledIND){
TwistDragon 0:68d9003ca160 25
TwistDragon 0:68d9003ca160 26 lcd.Clear(LCD_COLOR_BLACK);
TwistDragon 0:68d9003ca160 27
TwistDragon 0:68d9003ca160 28 ledIND = 0;
TwistDragon 0:68d9003ca160 29 wait(0.2);
TwistDragon 0:68d9003ca160 30 ledBL = 0;
TwistDragon 0:68d9003ca160 31 wait(0.2);
TwistDragon 0:68d9003ca160 32 ledGR = 0;
TwistDragon 0:68d9003ca160 33 wait(0.2);
TwistDragon 0:68d9003ca160 34 ledRE = 0;
TwistDragon 0:68d9003ca160 35 }
TwistDragon 0:68d9003ca160 36 else {
TwistDragon 0:68d9003ca160 37
TwistDragon 0:68d9003ca160 38 lcd.SetBackColor(LCD_COLOR_BLACK);
TwistDragon 0:68d9003ca160 39 lcd.SetTextColor(LCD_COLOR_WHITE);
TwistDragon 0:68d9003ca160 40 wait(0.2);
TwistDragon 0:68d9003ca160 41 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)result, CENTER_MODE);
TwistDragon 0:68d9003ca160 42
TwistDragon 0:68d9003ca160 43
TwistDragon 0:68d9003ca160 44
TwistDragon 0:68d9003ca160 45 ledIND = 1;
TwistDragon 0:68d9003ca160 46 wait(0.2);
TwistDragon 0:68d9003ca160 47 ledBL = 1;
TwistDragon 0:68d9003ca160 48 wait(0.2);
TwistDragon 0:68d9003ca160 49 ledGR = 1;
TwistDragon 0:68d9003ca160 50 wait(0.2);
TwistDragon 0:68d9003ca160 51 ledRE = 1;
TwistDragon 0:68d9003ca160 52 }
TwistDragon 0:68d9003ca160 53 prevValue = 1;
TwistDragon 0:68d9003ca160 54 }
TwistDragon 0:68d9003ca160 55 else if (button == 0){
TwistDragon 0:68d9003ca160 56 prevValue = 0;
TwistDragon 0:68d9003ca160 57 }
TwistDragon 0:68d9003ca160 58
TwistDragon 0:68d9003ca160 59 }
TwistDragon 0:68d9003ca160 60 }