motion sensor coding problem


The first help-step is showing you how to post code as a code-section:

  1. open your code in the Arduino-IDE
  2. press Ctrl.t for autoformatting your code
  3. do a right-click with your mouse and choose "copy for forum"
  4. press-alt-tab to change back to your browser
  5. press ctrl-v to insert the clipboard-content into the "write-post-field"
  6. add a detailed description what your code does and how it deviates from what you like the code to do

best regards Stefan

I want to light up two LEDs using the Pir motion sensor.
I want the 12th led to turn on after ten seconds.

Two LEDs and you want the 12th of the 2 to turn on? I guess you might mean the LED on pin 12?

Your code doesn't compile. So that's the first problem to fix.


Merhaba Sabri,

Bu metni Almanca yazdım ve ardından google-translate ile İngilizceye tercüme ettirdim. Sonra İngilizce çevirisini aldım ve Türkçe'ye tercüme ettirdim. Türkçe hiç konuşamıyorum. Yine de bu metni iyi anlayacağınıza eminim. Zaten iki google çeviri yapmış olmasına rağmen.

Yardımcı olabilecek kullanıcılar için mümkün olduğunca kolaylaştırmalısınız. Yardım istiyorsunuz, bu yüzden sorunuzu Türkçe yazın ve sonra google çevirsin.

çok selamlar Stefan

here in english:
Hello Sabri,

I wrote this text in German and then had it translated into English with google-translate. Then I took the English translation and had it translated into Turkish. I can't speak Turkish at all. Nevertheless, I am sure that you can understand this text well. Although he has already done two google translations.

You should make it as easy as possible for the users who could help. You want help so write your question in Turkish and then let google translate translate it.

many greetings Stefan

I wrote the question in English.but for some reason the computer recorded it in Turkish.
excuse me.I've just realized.
By the way, thank you very much for taking care of me

Here is a Google translation from Turkish back to English (with some manual fixes):

#define timeSeconds 10
const int led = 13;
unsigned long PresentTime = 0; // is variable, keeps the whole time.
unsigned long PreTime = 0; // variable holds the time detected by the PIR sensor.
unsigned range = 500; // is a time-identifying boolean variable when motion is detected.
boolean state = LOW;
int inputPin = 8;
int val = 0;

void setup ()
  Serial.begin (9600);
  pinMode (led, OUTPUT);
  pinMode (inputPin, INPUT);
  digitalWrite (inputPin, LOW);
  for (int i = 0; i < 10; i ++)
    delay (1000);

void loop ()
  PresentTime = millis();

  if (PresentTime - PreTime >= range)

    PreTime = PresentTime;
    val = digitalRead (inputPin);
    Serial.println (state);
    if (state == LOW && val == HIGH)
      Serial.println (val);
    state = HIGH;
    digitalWrite (inputPin, LOW);
  else if (state == HIGH && val == LOW)
    state = LOW;
  digitalWrite (led, state);
  digitalWrite (inputPin, HIGH);