Devices & Components
Microwave Radar Sensor RCWL-0516
Software & Tools
Arduino IDE
Project description
Code
Code
1int ledPin = 3; // Pin where the LED is hooked up 2int inputPin = 2; // Pin where teh Radar Sensor is hooked up 3int motion = 0; // State of motion 4 5 6void setup() { 7 pinMode(ledPin, OUTPUT); // Declare the LED pin as output 8 pinMode(inputPin, INPUT); // Declare the sensor pin as input 9 Serial.begin(9600); 10}; 11 12 13void loop() { 14 motion = digitalRead(inputPin); // Read the input pin 15 16 if (motion == HIGH) { 17 digitalWrite(ledPin, HIGH); // Turn on the LED 18 Serial.println("Motion Detected!"); 19 } else { 20 digitalWrite(ledPin, LOW); // Turn off the LED 21 Serial.println("No Motion Detected!"); 22 }; 23};
Comments
Only logged in users can leave comments