To make the testbed for mbed work with the SRF04 sensor.

Dependencies:   mbed

Fork of TestBed-LCD20x4 by Elmicro Computer

main.cpp

Committer:
jesb
Date:
2013-12-16
Revision:
1:abf7a830aa39
Parent:
0:7c694e032688

File content as of revision 1:abf7a830aa39:

#include "mbed.h"
#include "TextLCD.h"
DigitalIn echo(p18);
DigitalOut trigger(p17);
TextLCD lcd(p26, p25, p24, p23, p22, p20, p19, TextLCD::LCD20x4);

Timer t;
float i;

int main() {
        //Testen van het scherm
    lcd.printf("--UltraSonic Range--");
    wait(1);
    lcd.cls();  
    
    t.start();
     while(1) { 
            //Pulstrein 
        trigger=1;
        wait(0.00004);
        trigger=0;
        while(!echo);
        
        t.reset();
        while(echo);
        i=t.read_us();
        
        lcd.cls();
         lcd.printf("Pulse length= \n%6.0f us", i);              
         i=i/58.479;
         lcd.printf("\nDistance = %4.1f cm", i);  
         wait(0.2);
        }
}