//#include // import another program, a library, to communicate //#define rxpin 0 //#define txpin 1 //SoftwareSerial serial(rxpin,txpin); int rxPin = 0; // this is simular to the int = setting, however this is linked to the library int txPin = 1; int trig = 16; int echo = 17; int trig1 = 18; int echo1 = 19; long lecture_echo; long cm; int timeout = 1000; void setup() { pinMode(trig, OUTPUT); digitalWrite(trig, LOW); pinMode(echo, INPUT); pinMode(trig1, OUTPUT); digitalWrite(trig1, LOW); pinMode(echo1, INPUT); Serial.begin(9600); } void loop() { digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); lecture_echo = pulseIn(echo, HIGH, timeout*1000); cm = lecture_echo / 58; Serial.print ("sonar 1 in cm: "); Serial.println(cm); digitalWrite(trig1, HIGH); delayMicroseconds(10); digitalWrite(trig1, LOW); lecture_echo = pulseIn(echo1, HIGH, timeout*1000); //timeout in micro seconden cm = lecture_echo / 58; serial.print ("sonar 2 in cm: "); serial.println(cm); delay(timeout); }