Paso 5: código
#include
LiquidCrystal lcd (12, 11, 5, 4, 3, 2);
#include #define TRIGGER_PIN 6 #define ECHO_PIN 7 #define MAX_DISTANCE 200 NewPing sonar (TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {lcd.begin (16, 2); Serial.Begin(115200); }
void loop() {delay(50); unsigned int nos = sonar.ping(); Serial.Print ("Ping:"); LCD.Print(US / US_ROUNDTRIP_CM); LCD.Print("cm"); Delay(500); LCD.Clear(); }