#define sensorPin D10 const int rLED = D8; // red LED int motionState = LOW; // we start and assuming no motion detected int val = 0; // valuable for reading the pin status void setup() { Serial.begin(9600); pinMode(sensorPin, INPUT); pinMode(rLED, OUTPUT); } void loop() { while (digitalRead(sensorPin)==LOW); // Do nothing when the RCWL stay in LOW state digitalWrite(rLED, HIGH); // turn LED on Serial.println("Motion detected!"); while (digitalRead(sensorPin)!=LOW); // Do nothing when the RCWL stay in HIGH state digitalWrite(rLED, LOW) ; // turn LED off Serial.println("NO Motion");