Daniel Scarnatto
/
STM32F103C8T6_TextLCD
Simple analog input and LCD 4 bit Example reading a LM35. Tested in BluePill board
main.cpp
- Committer:
- dscarnatto
- Date:
- 2020-07-28
- Revision:
- 2:93417af6f469
- Parent:
- 1:e10c603cf0ae
File content as of revision 2:93417af6f469:
/* Hello World! for the TextLCD Enhanced Library*/ //Probado en el BluePill 27/07/20 #include "mbed.h" #include "TextLCD.h" // Host PC Communication channels //Serial pc(PA_2, PA_3); // tx, rx AnalogIn LM35(PA_7); // LCD instantiation TextLCD lcd(PB_4, PB_3, PB_12, PB_13, PB_14, PB_15, TextLCD::LCD20x4); // 4-bit bus: RS, E, D4, D5, D6, D7 Timer t; int main() { //pc.printf("TextLCD Enhanced Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows()); lcd.printf("Funka locoso"); float tempC,tempF,a[10],avg; int i; lcd.locate(0,1); while(1) { avg=0; //Toma 10 lecturas del LM35 for(i=0; i<10; i++) { a[i]=LM35.read(); wait(.02); } //Calcula el promedio for(i=0; i<10; i++) { avg=avg+(a[i]/10); } //Ajusta conversion tempC=(avg*3.685503686*100); tempF=(9.0*tempC)/5.0 + 32.0; //Imprime en LCD lcd.printf("Temp = %.0f C -> %.0f F\r\n", tempC,tempF); wait(1); lcd.locate(0,1); } }