PIR sensor + LED

Hello everyone, i'm new to arduino programming. As i try to use a motion sensor i find difficulty.
problem: when i run, the led lights up and stays that way, and in the serial monitor :"motion detected" andit stays that way (even if i don't move)

I used this as an example:

Help much appreciated

I'm new to arduino programming,
I used this example for my pir sensor : Arduino with PIR Motion Sensor | Random Nerd Tutorials

results are not as expected. the led turns on and stays that way. serial monitor says"motion detected" and nothing changes.

Can anybody tell me what's wrong!

We need to see your code, your schematic and a photo of your wiring.

We need to see your code, your schematic and a photo of your wiring.

I followed the tuto in this link:

No I did not ask what you followed I asked about what you have produced.

I am assuming what you followed was correct and you made a mistake, which you want us to tell you about. Without knowing what you did we can’t do that.

Your code copied and pasted from your machine allows us to see if you made any errors transposing that code and a photograph of your wiring shows us if you have got that right.

Threads merged.

Somehow, i did not see your comment.
Apologies. I’m going to provide what you asked.so the code is:

int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input


void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println(“Motion detected!”);
// We only want to print on the output change, not state
pirState = HIGH;
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println(“Motion ended!”);
// We only want to print on the output change, not state
pirState = LOW;

these picture show how i connected the device.
thank you for your help!

these picture show how i connected the device.

Sorry but they don't do any such thing.
One is an Arduino with a wire in 5V and Gnd. The next is the same thing but with a grey wire coming out of pin 2. And the final one has a PIR sensor with three wires coming from it. The white one appearing for the first time.

However I can see that you have got power and ground connected to the sensor the wrong way round.
I said:-

I am assuming what you followed was correct and you made a mistake,

Well I half take that back. The video does indeed show the correct wiring but the Fritzing crap layout has it wrong.
You can see from this still from the video that the ground is on the left. Your third picture would indicate the power and ground are swapped over.

The code should be in code tags not quote tags, code tags are the top left icon in the row and looks like </>.

I remember running into this Fritzing part when I was trying to help a friend of mine making his first Arduino project and wanted to provide him a breadboard layout. It was ridiculously difficult to modify that part in Fritzing. After that I wanted nothing more to do with the program.

I believe the reason for the part being that way is the PIR module Adafruit sells happens to have the opposite pinout from all the common cheap PIR modules you find everywhere else:

I seem to remember that Fritzing part was made by Adafruit.

To make things worse, some of the modules (like the one BeastHunter is using) have the pinout marked on the side of the PCB that's covered by the diffuser!

After reading your well detailed comments i did correct the mistake which was inverting GND and VCC wires on the sensor. I have feared destroying it if i have messed with that so i thought to ask first, and i would like to thank you all for the information that you provided.
I will learn more about electronics and this forum in order to make my posts more accurate and detailed.
Thank you.

BeastHunter, from the picture shown for your board it shows that you have not selected either the re-triggering Mode or the non retriggering mode. In the lower left corner you see three pads marked MD L and Hi. If you notice in the adafruit board shown by pert there a jumper provision is made. You may not have blown your PIR sensor.