![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Help me please
Diff: main.cpp
- Revision:
- 0:b78e02ab7cde
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 15 17:17:21 2020 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +#include "hcsr04.h" +#include <LiquidCrystal_I2C.h> + +// Set the LCD address to 0x27 for a 16 chars and 2 line display +LiquidCrystal_I2C lcd(0x4E, 16, 2); + + + +//D9 TRIGGER D8 ECHO + HCSR04 sensor(D8, D9); + + +int main() { + lcd.begin(); + lcd.backlight(); + lcd.print(" Ultrasonic"); + + //lcd.print("Distance = ",distance); //show on lcd 16x2 + + + while(1) { + int x = sensor.distance(); + printf("distance %d \n\r",x); //Test in Tera + wait(1.0); // 1 sec + lcd.setCursor(0,1); + lcd.print(" Ultrasonic",&x); + + } +} \ No newline at end of file