// Fab Academy 2023 - Fab Lab León // PIR sensor or Doppler radar // Fab-Xiao const int RadarPin = D0; // Digital input pin (RP2040 pin 26 or ESP32-C3 pin D0) const int LED_PIN = D1; // LED output pin void setup() { Serial.begin(115200); // Initialize serial communication pinMode(RadarPin, INPUT); // Set radar/PIR pin as input pinMode(LED_PIN, OUTPUT); // Set LED pin as output digitalWrite(LED_PIN, LOW); // Ensure LED is off initially } void loop() { int value = digitalRead(RadarPin); // Read the value from the sensor (0 or 1) if (value == HIGH) { digitalWrite(LED_PIN, HIGH); // Turn LED ON when motion detected Serial.println("Motion detected!"); } else { digitalWrite(LED_PIN, LOW); // Turn LED OFF when no motion Serial.println("No motion."); } delay(50); // Small delay to avoid excessive readings }