test TTL

Dependencies:   mbed TextLCD

main.cpp

Committer:
mehrnaz
Date:
2019-05-23
Revision:
1:fd5a598caa32
Parent:
0:a13b440d4fd1

File content as of revision 1:fd5a598caa32:

#include "mbed.h"
#include "flow.h"
#include "TextLCD.h"

Serial ttl(PA_0, PA_1);
PwmOut led(PB_6);
TextLCD lcd(PC_8,PC_6,PB_15,PB_14,PB_13,PB_12, TextLCD::LCD16x2);


int main()
{  

    flow();
    ttl.baud(9600);
    
    lcd.cls();
    wait(0.001);
    lcd.locate(3,0);
    lcd.printf("|");
    lcd.locate(4,0);
    lcd.printf("|");
    
    
    while(1) {
     
     lcd.locate(8,0);
    lcd.printf("f: %f\n", finalflow);
     
        //ttl.printf("flow: %f\n", finalflow);
        if (flow()<0.4)
        {
            lcd.locate(0,1);
            lcd.printf("*     ");
            led.write(0.00f);
        }
        if (flow()>=0.4 and flow()<1.5)
        {
            lcd.locate(0,1);
            lcd.printf("**    ");
            led.write(0.20f);
        }
        if (flow()>=1.5 and flow()<2.7)
        {
            lcd.locate(0,1);
            lcd.printf("***   ");
            led.write(0.40f);
        }
        if (flow()>=2.7 and flow()<3)
        {
            lcd.locate(0,1);
            lcd.printf("****  ");
            led.write(0.60f);
        }
        if (flow()>=3 and flow()<3.3)
        {
            lcd.locate(0,1);
            lcd.printf("***** ");
            led.write(0.80f);
        }
        if (flow()>=3.3)
        {
            lcd.locate(0,1);
            lcd.printf("******");
            led.write(1.00f);
        }
   // lcd.printf("%f\n", flow());
    wait (0.2);
                
    }
}