Quick mini project by us all. By Kelly, Kristian, Kristina and Zara.
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG mbed
main.cpp@0:93494a371b6e, 2018-10-15 (annotated)
- Committer:
- KellanySDE
- Date:
- Mon Oct 15 11:50:47 2018 +0000
- Revision:
- 0:93494a371b6e
- Child:
- 1:1e7a982213e8
Group project - quick
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
KellanySDE | 0:93494a371b6e | 1 | #include "mbed.h" //the library that is connected - h stands for HeaderFile |
KellanySDE | 0:93494a371b6e | 2 | #include "LCD_DISCO_F746NG.h" //Lib for the screen |
KellanySDE | 0:93494a371b6e | 3 | |
KellanySDE | 0:93494a371b6e | 4 | DigitalOut myled(D4); //the light that this program connect to. |
KellanySDE | 0:93494a371b6e | 5 | DigitalIn button(D3); //where the button are |
KellanySDE | 0:93494a371b6e | 6 | LCD_DISCO_F746NG lcd; //Define lcd as the LCD screen |
KellanySDE | 0:93494a371b6e | 7 | AnalogIn temper(A0); //Defines the temp sensor |
KellanySDE | 0:93494a371b6e | 8 | |
KellanySDE | 0:93494a371b6e | 9 | void Temp() { |
KellanySDE | 0:93494a371b6e | 10 | float temp; |
KellanySDE | 0:93494a371b6e | 11 | |
KellanySDE | 0:93494a371b6e | 12 | temp = temper.read()*27.21; //Reads the input |
KellanySDE | 0:93494a371b6e | 13 | char result[24]; |
KellanySDE | 0:93494a371b6e | 14 | snprintf(result, sizeof(result) |
KellanySDE | 0:93494a371b6e | 15 | ,"Current temp are: %f",temp); |
KellanySDE | 0:93494a371b6e | 16 | |
KellanySDE | 0:93494a371b6e | 17 | lcd.SetBackColor(LCD_COLOR_BLACK); |
KellanySDE | 0:93494a371b6e | 18 | lcd.SetTextColor(LCD_COLOR_WHITE); |
KellanySDE | 0:93494a371b6e | 19 | lcd.DisplayStringAt( 0, LINE(5),(uint8_t*)result, CENTER_MODE); |
KellanySDE | 0:93494a371b6e | 20 | wait(.2); |
KellanySDE | 0:93494a371b6e | 21 | |
KellanySDE | 0:93494a371b6e | 22 | }; |
KellanySDE | 0:93494a371b6e | 23 | |
KellanySDE | 0:93494a371b6e | 24 | void ButtonText() { |
KellanySDE | 0:93494a371b6e | 25 | while (1) { |
KellanySDE | 0:93494a371b6e | 26 | if (button) { |
KellanySDE | 0:93494a371b6e | 27 | myled = 1; |
KellanySDE | 0:93494a371b6e | 28 | lcd.SetBackColor(LCD_COLOR_BLACK); |
KellanySDE | 0:93494a371b6e | 29 | lcd.SetTextColor(LCD_COLOR_WHITE); |
KellanySDE | 0:93494a371b6e | 30 | lcd.Clear(LCD_COLOR_BLACK); |
KellanySDE | 0:93494a371b6e | 31 | lcd.DisplayStringAt( 0, LINE(5),(uint8_t*)"Wow... Perfect.", CENTER_MODE); |
KellanySDE | 0:93494a371b6e | 32 | lcd.DisplayStringAt( 0, LINE(6),(uint8_t*)"You pressed my button!", CENTER_MODE); |
KellanySDE | 0:93494a371b6e | 33 | wait(.5); |
KellanySDE | 0:93494a371b6e | 34 | } else { |
KellanySDE | 0:93494a371b6e | 35 | myled = 0; |
KellanySDE | 0:93494a371b6e | 36 | lcd.Clear(LCD_COLOR_BLACK); |
KellanySDE | 0:93494a371b6e | 37 | Temp(); |
KellanySDE | 0:93494a371b6e | 38 | } |
KellanySDE | 0:93494a371b6e | 39 | } |
KellanySDE | 0:93494a371b6e | 40 | }; |
KellanySDE | 0:93494a371b6e | 41 | |
KellanySDE | 0:93494a371b6e | 42 | |
KellanySDE | 0:93494a371b6e | 43 | int main() { //function - integer (numbers) |
KellanySDE | 0:93494a371b6e | 44 | ButtonText(); |
KellanySDE | 0:93494a371b6e | 45 | }; |