#include // import another program, a library, to communicate #define rxpin 1 #define txpin 0 SoftwareSerial serial(rxpin,txpin); int rxPin = 1; // this is simular to the int = setting, however this is linked to the library int txPin = 0; int trig = 6; int echo = 5; long lecture_echo; long cm; void setup() { pinMode(trig, OUTPUT); digitalWrite(trig, LOW); pinMode(echo, INPUT); serial.begin(9600); } void loop() { digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); lecture_echo = pulseIn(echo, HIGH); cm = lecture_echo / 58; serial.print ("Distance in cm: "); serial.println(cm); delay(1000); }