#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#define PIN_TRIG 15
#define PIN_ECHO 2
#define PIN_TRIG2 23
#define PIN_ECHO2 22
void setup() {
lcd.begin(16, 2);
Serial.begin(115200);
pinMode(PIN_TRIG, OUTPUT);
pinMode(PIN_ECHO, INPUT);
pinMode(PIN_TRIG2, OUTPUT);
pinMode(PIN_ECHO2, INPUT);
lcd.print("Hello World!");
}
void loop() {
// Start a new measurement:
digitalWrite(PIN_TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(PIN_TRIG, LOW);
// Read the result:
int duration = pulseIn(PIN_ECHO, HIGH);
Serial.print("Distance in CM: ");
Serial.println(duration / 58);
delay(1000);
digitalWrite(PIN_TRIG2, HIGH);
delayMicroseconds(10);
digitalWrite(PIN_TRIG2, LOW);
// Read the result:
int duration2 = pulseIn(PIN_ECHO2, HIGH);
Serial.print("Distance in CM2: ");
Serial.println(duration2 / 58);
delay(1000);
}