Embedded software / Mbed 2 deprecated poging2-lcd-sensor

Dependencies:   mbed

Fork of TestBed-LCD20x4 by Elmicro Computer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 DigitalIn echo(p18);
00004 DigitalOut trigger(p17);
00005 TextLCD lcd(p26, p25, p24, p23, p22, p20, p19, TextLCD::LCD20x4);
00006 
00007 Timer t;
00008 float i;
00009 
00010 int main() {
00011         //Testen van het scherm
00012     lcd.printf("--UltraSonic Range--");
00013     wait(1);
00014     lcd.cls();  
00015     
00016     t.start();
00017      while(1) { 
00018             //Pulstrein 
00019         trigger=1;
00020         wait(0.00004);
00021         trigger=0;
00022         while(!echo);
00023         
00024         t.reset();
00025         while(echo);
00026         i=t.read_us();
00027         
00028         lcd.cls();
00029          lcd.printf("Pulse length= \n%6.0f us", i);              
00030          i=i/58.479;
00031          lcd.printf("\nDistance = %4.1f cm", i);  
00032          wait(0.2);
00033         }
00034 }