The example program for mbed pin-compatible platforms

Dependencies:   mbed TextLCD

main.cpp

Committer:
rougoubossj
Date:
2021-06-03
Revision:
25:3c3773f3dbd8
Parent:
24:7f14b70fc9ef

File content as of revision 25:3c3773f3dbd8:

#include "mbed.h"
#include "TextLCD.h"
DigitalOut myled(LED1);

DigitalIn first(PA_8);
DigitalIn second(PB_10);

AnalogIn PA0(PA_0);
AnalogIn PA4(PA_4);

Serial pc(SERIAL_TX,SERIAL_RX);

void affiche_temperature();
void affiche_pression();

TextLCD lcd(PC_7, PA_7, PA_6, PA_5, PB_9, PB_8);


int main() {
     
     
     lcd.printf(" Hello World! \n");
     wait(2);
     lcd.cls(); 
     while(1){
         if ((first==1)&&(second==0))     affiche_temperature();  
         //if(first==1) ;
         else if ((first==0)&&(second==1))   affiche_pression(); 
         else  
            {
                lcd.printf("which value u want to know");
                wait(1); 
                lcd.cls(); 
                lcd.printf("1. Temperature\n2. Pression\n");
                wait(1); 
                lcd.cls(); 
                lcd.printf("3.vitesse\n4.direction\n");
                wait(1); 
                lcd.cls(); 
            }
     }
         
         


}


void affiche_temperature(){

        float value_tem = 0.0;
        float temperature = 0.0;
        value_tem = PA0.read();
  //      lcd.printf("\n \r value_tem = %f", value_tem);
 
        
        temperature = ((value_tem*3.3f + 0.7815f )/0.01f)- 273.15f;
        lcd.printf(" T= %.2f C\n", temperature);
        
        wait(2); 
        lcd.cls();  
    
}

void affiche_pression(){
        float value_pre = 0.0;
        float pression = 0.0;
        value_pre = PA4.read();
//      lcd.printf("\n \r  value_pre= %f", value_pre);
    
        
        pression  = (((value_pre *3.3f + 0.0902f)/3.3f ) + 0.095f) / 0.009f;
        lcd.printf(" P = %.2f kPa", pression);
        
        wait(3); 
        lcd.cls();  
    
}