Stap 5: Code
#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 ons = sonar.ping(); Serial.Print ("Ping:"); LCD.Print(US / US_ROUNDTRIP_CM); LCD.Print("cm"); delay(500); LCD.Clear(); }