Buenas!

Como hago que el sensor ultrasonico cierre la valvula de solenoide cuadno el agua este a 20cm del ping?

#include <NewPing.h>

int RELAY = 2;  // RELAY Pin.  
#define TRIGGER_PIN = 4; // Trigger Pin
#define ECHO_PIN = 5; // Echo Pin
int Dist; // The Distance value
#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.


void setup() {
  pinMode(RELAY, OUTPUT); //To the relay via the transistor
  Dist = 20; //The distance in inches. Change this for increasted or dicreasted range.
}

void loop() {
MAX_DISTANCE = sonar.Ranging(CM); // Range is calculated in Centimeters.
  
  
  if (MAX_DISTANCE < Dist) {
    digitalWrite(RELAY, HIGH);   
  } else if (MAX_DISTANCE > Dist) {
    digitalWrite(RELAY, LOW);
     delay(2000);
  }

}

me da error

sketch_may29a:9: error: expected primary-expression before '=' token
sketch_may29a:9: error: expected unqualified-id before ',' token
sketch_may29a:9: error: expected unqualified-id before '=' token
sketch_may29a:9: error: expected unqualified-id before ',' token
sketch_may29a:9: error: expected unqualified-id before numeric constant
sketch_may29a.ino: In function 'void loop()':
sketch_may29a:18: error: 'class NewPing' has no member named 'Ranging'
sketch_may29a:18: error: 'CM' was not declared in this scope

Muchas gracias!