const int trigPin = 4; const int echoPin = 3; long duration; //Use the Long data type to contain integer numbers that are too large to fit in the Integer data type The default value of Long is 0. int distance; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input } void loop() { // put your main code here, to run repeatedly: int x = analogRead(A1); int y = analogRead(A2); digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); Serial.print("soil: "); Serial.println(x); Serial.print("light: "); Serial.println(y); delay(1000); Serial.println(""); }