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

Dependencies:   mbed

Fork of TestBed-LCD20x4 by Elmicro Computer

Committer:
jesb
Date:
Mon Dec 16 11:57:45 2013 +0000
Revision:
1:abf7a830aa39
Parent:
0:7c694e032688
To make the Testbed for mbed work with the SRF04 sensor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmicro 0:7c694e032688 1 #include "mbed.h"
elmicro 0:7c694e032688 2 #include "TextLCD.h"
jesb 1:abf7a830aa39 3 DigitalIn echo(p18);
jesb 1:abf7a830aa39 4 DigitalOut trigger(p17);
jesb 1:abf7a830aa39 5 TextLCD lcd(p26, p25, p24, p23, p22, p20, p19, TextLCD::LCD20x4);
elmicro 0:7c694e032688 6
jesb 1:abf7a830aa39 7 Timer t;
jesb 1:abf7a830aa39 8 float i;
elmicro 0:7c694e032688 9
elmicro 0:7c694e032688 10 int main() {
jesb 1:abf7a830aa39 11 //Testen van het scherm
jesb 1:abf7a830aa39 12 lcd.printf("--UltraSonic Range--");
jesb 1:abf7a830aa39 13 wait(1);
jesb 1:abf7a830aa39 14 lcd.cls();
elmicro 0:7c694e032688 15
jesb 1:abf7a830aa39 16 t.start();
jesb 1:abf7a830aa39 17 while(1) {
jesb 1:abf7a830aa39 18 //Pulstrein
jesb 1:abf7a830aa39 19 trigger=1;
jesb 1:abf7a830aa39 20 wait(0.00004);
jesb 1:abf7a830aa39 21 trigger=0;
jesb 1:abf7a830aa39 22 while(!echo);
jesb 1:abf7a830aa39 23
jesb 1:abf7a830aa39 24 t.reset();
jesb 1:abf7a830aa39 25 while(echo);
jesb 1:abf7a830aa39 26 i=t.read_us();
jesb 1:abf7a830aa39 27
jesb 1:abf7a830aa39 28 lcd.cls();
jesb 1:abf7a830aa39 29 lcd.printf("Pulse length= \n%6.0f us", i);
jesb 1:abf7a830aa39 30 i=i/58.479;
jesb 1:abf7a830aa39 31 lcd.printf("\nDistance = %4.1f cm", i);
jesb 1:abf7a830aa39 32 wait(0.2);
jesb 1:abf7a830aa39 33 }
elmicro 0:7c694e032688 34 }